Changeset a9c7f3e in flex_extract.git


Ignore:
Timestamp:
Nov 26, 2018, 3:36:38 PM (2 weeks ago)
Author:
anphi <anne.philipp@…>
Branches:
master
Children:
fb8810c
Parents:
ceea034
Message:

added docu for request output and added header for request file; renamed request file

Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • python/FlexpartTools.py

    r51f9853 ra9c7f3e  
    197197
    198198    if c.request != '0':
    199         marsfile = os.path.join(c.inputdir, 'mars_request.csv')
     199        marsfile = os.path.join(c.inputdir, 'mars_requests.csv')
    200200        if os.path.isfile(marsfile):
    201201            os.remove(marsfile)
     
    578578            if not hasattr(self,'request'):
    579579                self.request='0'
     580            elif self.request != 0:
     581                marsfile = os.path.join(self.inputdir,
     582                                        'mars_requests.csv')
     583                if os.path.isfile(marsfile):
     584                    silentremove(marsfile)
    580585
    581586        return
     
    675680
    676681        # Get all class attributes and their values as a dictionary
    677         attrs = vars(self)
     682        attrs = vars(self).copy()
    678683        del attrs['server']
     684        del attrs['public']
    679685
    680686        # open a file to store all requests to
    681         with open(os.path.join(inputdir, 'mars_request.csv'), 'a') as f:
     687        with open(os.path.join(inputdir, 'mars_requests.csv'), 'a') as f:
    682688            f.write(str(request_number) + ', ')
    683689            f.write(', '.join(str(attrs[key])
     
    14751481                for k in l:
    14761482                    key_vals.append(str(k))
    1477 
    1478             index_vals.append(key_vals)
     1483   
     1484                index_vals.append(key_vals)
    14791485
    14801486
  • python/getMARSdata.py

    r51f9853 ra9c7f3e  
    5858    if not os.path.exists(c.inputdir):
    5959        os.makedirs(c.inputdir)
     60
     61
     62    if c.request == 0:
     63        print("Retrieving EC data!")
     64    else:
     65        if c.request == 1:
     66            print("Printing mars requests!")
     67        elif c.request == 2:
     68            print("Retrieving EC data and printing mars request!")
     69        # first, write header with the mars parameter to file
     70        # create a dummy MarsRetrieval to get parameter
     71        MR = MARSretrieval(None, None)
     72        attrs = vars(MR).copy()
     73        del attrs['server']
     74        del attrs['public']
     75        marsfile = os.path.join(c.inputdir, 'mars_request.csv')
     76        with open(marsfile, 'w') as f:
     77            f.write('request_number' + ', ')
     78            f.write(', '.join(str(key) for key in sorted(attrs.iterkeys())))
     79            f.write('\n')
     80
    6081    print "start date %s "%(c.start_date)
    6182    print "end date %s "%(c.end_date)
    62    
    63     if c.request == '0' or c.request == '2':
    64         print("Retrieving EC data!")
    65     elif c.request == '1':
    66         print("Printing mars requests!")
    6783
    6884    if ecapi:
     
    96112
    97113    datechunk=datetime.timedelta(days=int(c.date_chunk))
    98     if c.request == '0' or c.request == '2':
     114    if c.request == '0' or c.request == '2':
    99115        print 'removing content of '+c.inputdir
    100116        tobecleaned=glob.glob(c.inputdir+'/*_acc_*.'+str(os.getppid())+'.*.grb')
     
    136152
    137153    if c.request == '0' or c.request == '2':
    138         print 'removing content of '+c.inputdir
     154        print 'removing content of '+c.inputdir
    139155        tobecleaned=glob.glob(c.inputdir+'/*__*.'+str(os.getppid())+'.*.grb')
    140156        for f in tobecleaned:
    141157            os.remove(f)
    142            
     158
    143159    day=start
    144160    times=None
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG