TNO Intern

Commit 7bfd9ec3 authored by Arjo Segers's avatar Arjo Segers
Browse files

Trap non-existing or empty listing files when creating catalogue of converted data.

parent a1e55a98
Loading
Loading
Loading
Loading
+191 −169
Original line number Diff line number Diff line
#
# Changes
# 
# 2022-09, Arjo Segers, Met-Norway
#   Trap non-existing or empty listing files when creating catalogue of converted data.
#

########################################################################
###
@@ -283,12 +289,26 @@ class CSO_Catalogue( CSO_CatalogueBase ) :
        
        # listing file:
        lstfile = self.GetSetting( 'input.listing' )
        # base path, filenames are relative to listing file:
        inputdir = os.path.dirname( lstfile )
        # info ...
        logging.info( 'listing file:' )
        logging.info( '  %s' % lstfile )
        # should exist ...
        if not os.path.isfile(lstfile) :
            logging.error( 'file not found: %s' % lstfile )
            raise Exception
        #endif
        # read listing:
        lst = cso_file.CSO_Listing( lstfile, indent=indent )
        # subset of files in timerange:
        df = lst.Select( tr=(t1,t2) )
        # number of records:        
        nrec = len(df)
        
        # info ...
        logging.info( '  records within timerange: %i' % nrec )

        # any data?
        if nrec > 0 : 
        
            # variables to be plotted:
            varnames = self.GetSetting( 'vars' ).split()
@@ -471,6 +491,8 @@ class CSO_Catalogue( CSO_CatalogueBase ) :
                df.to_csv( os.path.join(figdir,'orbits.csv'), index=False, sep=';' )
            #endfor

        #endif # nrec > 0
    
        # back:
        os.chdir( owd )