Changeset 295ff45 in flex_extract.git for source/python/classes/MarsRetrieval.py


Ignore:
Timestamp:
Sep 29, 2018, 1:18:15 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
65748f4
Parents:
7b4e39e
Message:

added request output option also for basetime requests; changed output to csv format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/python/classes/MarsRetrieval.py

    r25b14be r295ff45  
    335335
    336336
    337     def print_info(self, inputdir):
     337    def print_info(self, inputdir, request_number):
    338338        '''
    339339        @Description:
     
    348348                The path where all data from the retrievals are stored.
    349349
    350         @Return:
     350            request_number: integer
     351                Number of mars requests for flux and non-flux data.
     352
     353            @Return:
    351354            <nothing>
    352355        '''
     
    357360        with open(os.path.join(inputdir,
    358361                               _config.FILE_MARS_REQUESTS), 'a') as f:
    359             f.write('mars\n')
     362            f.write('mars_request #' + str(request_number) + '\n')
    360363            # iterate through all attributes and print them
    361364            # with their corresponding values
     
    366369                    f.write(item[0] + ': ' + str(item[1]) + '\n')
    367370            f.write('\n\n')
     371
     372        return
     373
     374
     375    def print_infodata_csv(self, inputdir, request_number):
     376        '''
     377        @Description:
     378            Write all request parameter in alpabetical order into a "csv" file.
     379
     380        @Input:
     381            self: instance of MarsRetrieval
     382                For description see class documentation.
     383
     384            inputdir: string
     385                The path where all data from the retrievals are stored.
     386
     387            request_number: integer
     388                Number of mars requests for flux and non-flux data.
     389
     390        @Return:
     391            <nothing>
     392        '''
     393
     394        # Get all class attributes and their values as a dictionary
     395        attrs = vars(self)
     396        del attrs['server']
     397
     398        # open a file to store all requests to
     399        with open(os.path.join(inputdir,
     400                                   _config.FILE_MARS_REQUESTS), 'a') as f:
     401            f.write(str(request_number) + ', ')
     402            f.write(', '.join(str(attrs[key])
     403                              for key in sorted(attrs.iterkeys())))
     404            f.write('\n')
    368405
    369406        return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG