Esempio n. 1
0
def autonc2xl(cf,InLevel,OutLevel):
    # get the variables
    ds = nc_read_series(cf,InLevel)
    # write the variables to the excel file
    if putils.cfkeycheck(cf,Base='Output',ThisOne='Format') and cf['Output']['Format'] == 'Subset':
        xl_write_series(cf,ds,OutLevel)
    else:
        xl_write_library(cf,ds,OutLevel)
 def do_xl2ncCall(self):
     self.do_progress(text='Load xl2nc Control File ...')
     self.cf = pio.loadcontrolfile('../controlfiles')
     if len(self.cf)==0:
         self.do_progress(text='Waiting for input ...')
         return
     self.do_progress(text='Importing Xcel file -> NetCDF v4 ...')
     if putils.cfkeycheck(self.cf,'General','InLevel') and putils.cfkeycheck(self.cf,'General','OutLevel'):
         InLevel = self.cf['General']['InLevel']
         OutLevel = self.cf['General']['OutLevel']
     else:
         InLevel = 'L3'
         OutLevel = 'L3'
     pio.autoxl2nc(self.cf,InLevel,OutLevel)
     self.do_progress(text='Finished Data Ingest')
     log.info(' Finished Data Ingest')
     print '\a'
 def do_savexL6(self):
     self.do_progress(text='Exporting L4 Diurnal NetCDF -> Xcel ...')                     # put up the progress message
     if (putils.cfkeycheck(self.cf,'Output','DefaultXl') and self.cf['Output']['DefaultXl'] == 'False'):
         self.cf = pio.loadcontrolfile('../controlfiles')
         if len(self.cf)==0:
             self.do_progress(text='Waiting for input ...')
             return
     if putils.cfkeycheck(self.cf,Base='General',ThisOne='InputLevel') and putils.cfkeycheck(self.cf,Base='General',ThisOne='OutputLevel'):
         InLevel = self.cf['General']['InputLevel']
         OutLevel = self.cf['General']['OutputLevel']
     else:
         InLevel = 'L3'
         OutLevel = 'Partitioning'
     
     pio.autonc2xl(self.cf,InLevel,OutLevel)
     self.do_progress(text='Finished L4 Data Export')              # tell the user we are done
     log.info(' Finished saving L4 data')
     print '\a'
Esempio n. 4
0
 def do_xl2ncCall(self):
     self.do_progress(text='Load xl2nc Control File ...')
     self.cf = pio.loadcontrolfile('../controlfiles')
     if len(self.cf) == 0:
         self.do_progress(text='Waiting for input ...')
         return
     self.do_progress(text='Importing Xcel file -> NetCDF v4 ...')
     if putils.cfkeycheck(self.cf, 'General',
                          'InLevel') and putils.cfkeycheck(
                              self.cf, 'General', 'OutLevel'):
         InLevel = self.cf['General']['InLevel']
         OutLevel = self.cf['General']['OutLevel']
     else:
         InLevel = 'L3'
         OutLevel = 'L3'
     pio.autoxl2nc(self.cf, InLevel, OutLevel)
     self.do_progress(text='Finished Data Ingest')
     log.info(' Finished Data Ingest')
     print '\a'
Esempio n. 5
0
def autonc2xl(cf, InLevel, OutLevel):
    # get the variables
    ds = nc_read_series(cf, InLevel)
    # write the variables to the excel file
    if putils.cfkeycheck(
            cf, Base='Output',
            ThisOne='Format') and cf['Output']['Format'] == 'Subset':
        xl_write_series(cf, ds, OutLevel)
    else:
        xl_write_library(cf, ds, OutLevel)
Esempio n. 6
0
def l3partition(cf,ds2):
    '''Processing OzFlux_Level3 data for partitioning'''
    # make a copy of the OzFlux_Level3 data
    ds3 = copy.deepcopy(ds2)
    ds3.globalattributes['Level'] = 'L5'
    # compute daily statistics
    if putils.cfkeycheck(cf,Base='Params',ThisOne='firstMonth'):
        M1st = int(cf['Params']['firstMonth'])
    else:
        M1st = 1
    if putils.cfkeycheck(cf,Base='Params',ThisOne='secondMonth'):
        M2nd = int(cf['Params']['secondMonth'])
    else:
        M2nd = 12
    # prep nighttime ER observations
    pts.ER_nightL3(cf,ds3,M1st,M2nd,'Fc')
    pts.LightResponseCurves(ds3)
    log.info('L3 Partitioning: All done')
    return ds3
 def do_l3_er_night(self):
     self.cf = pio.loadcontrolfile('../controlfiles')
     if len(self.cf)==0:
         self.do_progress(text='Waiting for input ...')
         return
     if putils.cfkeycheck(self.cf,Base='General',ThisOne='InputLevel'):
         InLevel = self.cf['General']['InputLevel']
     else:
         InLevel = 'L3'
     self.ds2 = pio.nc_read_series(self.cf,InLevel)
     self.do_progress(text='Doing partitioning prep...')
     self.ds3 = pls.l3partition(self.cf,self.ds2)
     self.do_progress(text='Finished partitioning prep')
     self.do_progress(text='Saving L3 Partitioning NetCDF data ...')                     # put up the progress message
     if putils.cfkeycheck(self.cf,Base='General',ThisOne='OutputLevel'):
         OutLevel = self.cf['General']['OutputLevel']
     else:
         OutLevel = 'Partitioning'
     pio.nc_write_series(self.cf,self.ds3,OutLevel)                   # save the L3 data
     self.do_progress(text='Finished L3 ER_night Partitioning')              # tell the user we are done
     log.info(' Finished saving L3 Partitioning NetCDF data')
     print '\a'
 def do_l6_partition(self):
     self.cf = pio.loadcontrolfile('../controlfiles')
     if len(self.cf)==0:
         self.do_progress(text='Waiting for input ...')
         return
     if putils.cfkeycheck(self.cf,Base='General',ThisOne='InputLevel'):
         InLevel = self.cf['General']['InputLevel']
     else:
         InLevel = 'L5'
     self.ds5 = pio.nc_read_series(self.cf,InLevel)
     self.do_progress(text='Partitioning daytime ER_dark and GPP...')
     self.ds6 = pls.l6partition(self.cf,self.ds5)
     self.do_progress(text='Finished partitioning daytime ER_dark and GPP')
     self.do_progress(text='Saving L4 Partitioning NetCDF data ...')                     # put up the progress message
     if putils.cfkeycheck(self.cf,Base='General',ThisOne='OutputLevel'):
         OutLevel = self.cf['General']['OutputLevel']
     else:
         OutLevel = 'Partitioning'
     pio.nc_write_series(self.cf,self.ds6,OutLevel)                   # save the L3 data
     self.do_progress(text='Finished L6 Partitioning')              # tell the user we are done
     log.info(' Finished saving L6 Partitioning NetCDF data')
     print '\a'
Esempio n. 9
0
    def do_savexL6(self):
        self.do_progress(text='Exporting L4 Diurnal NetCDF -> Xcel ...'
                         )  # put up the progress message
        if (putils.cfkeycheck(self.cf, 'Output', 'DefaultXl')
                and self.cf['Output']['DefaultXl'] == 'False'):
            self.cf = pio.loadcontrolfile('../controlfiles')
            if len(self.cf) == 0:
                self.do_progress(text='Waiting for input ...')
                return
        if putils.cfkeycheck(
                self.cf, Base='General',
                ThisOne='InputLevel') and putils.cfkeycheck(
                    self.cf, Base='General', ThisOne='OutputLevel'):
            InLevel = self.cf['General']['InputLevel']
            OutLevel = self.cf['General']['OutputLevel']
        else:
            InLevel = 'L3'
            OutLevel = 'Partitioning'

        pio.autonc2xl(self.cf, InLevel, OutLevel)
        self.do_progress(
            text='Finished L4 Data Export')  # tell the user we are done
        log.info(' Finished saving L4 data')
        print '\a'
Esempio n. 10
0
 def do_l3_er_night(self):
     self.cf = pio.loadcontrolfile('../controlfiles')
     if len(self.cf) == 0:
         self.do_progress(text='Waiting for input ...')
         return
     if putils.cfkeycheck(self.cf, Base='General', ThisOne='InputLevel'):
         InLevel = self.cf['General']['InputLevel']
     else:
         InLevel = 'L3'
     self.ds2 = pio.nc_read_series(self.cf, InLevel)
     self.do_progress(text='Doing partitioning prep...')
     self.ds3 = pls.l3partition(self.cf, self.ds2)
     self.do_progress(text='Finished partitioning prep')
     self.do_progress(text='Saving L3 Partitioning NetCDF data ...'
                      )  # put up the progress message
     if putils.cfkeycheck(self.cf, Base='General', ThisOne='OutputLevel'):
         OutLevel = self.cf['General']['OutputLevel']
     else:
         OutLevel = 'Partitioning'
     pio.nc_write_series(self.cf, self.ds3, OutLevel)  # save the L3 data
     self.do_progress(text='Finished L3 ER_night Partitioning'
                      )  # tell the user we are done
     log.info(' Finished saving L3 Partitioning NetCDF data')
     print '\a'
Esempio n. 11
0
 def do_l6_partition(self):
     self.cf = pio.loadcontrolfile('../controlfiles')
     if len(self.cf) == 0:
         self.do_progress(text='Waiting for input ...')
         return
     if putils.cfkeycheck(self.cf, Base='General', ThisOne='InputLevel'):
         InLevel = self.cf['General']['InputLevel']
     else:
         InLevel = 'L5'
     self.ds5 = pio.nc_read_series(self.cf, InLevel)
     self.do_progress(text='Partitioning daytime ER_dark and GPP...')
     self.ds6 = pls.l6partition(self.cf, self.ds5)
     self.do_progress(text='Finished partitioning daytime ER_dark and GPP')
     self.do_progress(text='Saving L4 Partitioning NetCDF data ...'
                      )  # put up the progress message
     if putils.cfkeycheck(self.cf, Base='General', ThisOne='OutputLevel'):
         OutLevel = self.cf['General']['OutputLevel']
     else:
         OutLevel = 'Partitioning'
     pio.nc_write_series(self.cf, self.ds6, OutLevel)  # save the L3 data
     self.do_progress(
         text='Finished L6 Partitioning')  # tell the user we are done
     log.info(' Finished saving L6 Partitioning NetCDF data')
     print '\a'
Esempio n. 12
0
def nc_write_series(cf, ds, level):
    ncFullName = cf['Files'][level]['ncFilePath'] + cf['Files'][level][
        'ncFileName']
    log.info(' Writing netCDF file ' + ncFullName)
    if putils.cfkeycheck(
            cf, Base='General',
            ThisOne='netCDFv3') and cf['General']['netCDFv3'] == 'False':
        ncFile = netCDF4.Dataset(ncFullName, 'w')
    else:
        ncFile = netCDF4.Dataset(ncFullName, 'w', format='NETCDF3_CLASSIC')
    for ThisOne in ds.globalattributes.keys():
        setattr(ncFile, ThisOne, ds.globalattributes[ThisOne])
    t = time.localtime()
    RunDateTime = str(datetime.datetime(t[0], t[1], t[2], t[3], t[4], t[5]))
    setattr(ncFile, 'RunDateTime', RunDateTime)
    nRecs = len(ds.series['xlDateTime']['Data'])
    setattr(ncFile, 'NumRecs', str(nRecs))
    setattr(ncFile, 'Level', level)
    ncFile.createDimension('Time', nRecs)
    SeriesList = ds.series.keys()
    for ThisOne in [
            'xlDateTime', 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second',
            'Hdh'
    ]:
        if ThisOne in SeriesList:
            dt = get_ncdtype(ds.series[ThisOne]['Data'])
            ncVar = ncFile.createVariable(ThisOne, dt, ('Time', ))
            ncVar[:] = ds.series[ThisOne]['Data'].tolist()
            setattr(ncVar, 'long_name', ThisOne)
            setattr(ncVar, 'units', 'none')
            SeriesList.remove(ThisOne)
    if 'DateTime' in SeriesList:
        SeriesList.remove('DateTime')
    for ThisOne in SeriesList:
        if 'Data' in ds.series[ThisOne].keys():
            dt = get_ncdtype(ds.series[ThisOne]['Data'])
            ncVar = ncFile.createVariable(ThisOne, dt, ('Time', ))
            ncVar[:] = ds.series[ThisOne]['Data'].tolist()
        if 'Attr' in ds.series[ThisOne].keys():
            for attr in ds.series[ThisOne]['Attr']:
                setattr(ncVar, attr, ds.series[ThisOne]['Attr'][attr])
        if 'Flag' in ds.series[ThisOne].keys():
            dt = get_ncdtype(ds.series[ThisOne]['Flag'])
            ncVar = ncFile.createVariable(ThisOne + '_QCFlag', dt, ('Time', ))
            ncVar[:] = ds.series[ThisOne]['Flag'].tolist()
            setattr(ncVar, 'long_name', 'QC flag')
            setattr(ncVar, 'units', 'none')
    ncFile.close()
Esempio n. 13
0
def nc_write_series(cf,ds,level):
    ncFullName = cf['Files'][level]['ncFilePath']+cf['Files'][level]['ncFileName']
    log.info(' Writing netCDF file '+ncFullName)
    if putils.cfkeycheck(cf,Base='General',ThisOne='netCDFv3') and cf['General']['netCDFv3'] == 'False':
        ncFile = netCDF4.Dataset(ncFullName,'w')
    else:
        ncFile = netCDF4.Dataset(ncFullName,'w',format='NETCDF3_CLASSIC')
    for ThisOne in ds.globalattributes.keys():
        setattr(ncFile,ThisOne,ds.globalattributes[ThisOne])
    t = time.localtime()
    RunDateTime = str(datetime.datetime(t[0],t[1],t[2],t[3],t[4],t[5]))
    setattr(ncFile,'RunDateTime',RunDateTime)
    nRecs = len(ds.series['xlDateTime']['Data'])
    setattr(ncFile,'NumRecs',str(nRecs))
    setattr(ncFile,'Level',level)
    ncFile.createDimension('Time',nRecs)
    SeriesList = ds.series.keys()
    for ThisOne in ['xlDateTime','Year','Month','Day','Hour','Minute','Second','Hdh']:
        if ThisOne in SeriesList:
            dt = get_ncdtype(ds.series[ThisOne]['Data'])
            ncVar = ncFile.createVariable(ThisOne,dt,('Time',))
            ncVar[:] = ds.series[ThisOne]['Data'].tolist()
            setattr(ncVar,'long_name',ThisOne)
            setattr(ncVar,'units','none')
            SeriesList.remove(ThisOne)
    if 'DateTime' in SeriesList:
        SeriesList.remove('DateTime')
    for ThisOne in SeriesList:
        if 'Data' in ds.series[ThisOne].keys():
            dt = get_ncdtype(ds.series[ThisOne]['Data'])
            ncVar = ncFile.createVariable(ThisOne,dt,('Time',))
            ncVar[:] = ds.series[ThisOne]['Data'].tolist()
        if 'Attr' in ds.series[ThisOne].keys():
            for attr in ds.series[ThisOne]['Attr']:
                setattr(ncVar,attr,ds.series[ThisOne]['Attr'][attr])
        if 'Flag' in ds.series[ThisOne].keys():
            dt = get_ncdtype(ds.series[ThisOne]['Flag'])
            ncVar = ncFile.createVariable(ThisOne+'_QCFlag',dt,('Time',))
            ncVar[:] = ds.series[ThisOne]['Flag'].tolist()
            setattr(ncVar,'long_name','QC flag')
            setattr(ncVar,'units','none')
    ncFile.close()
Esempio n. 14
0
def xl_write_series(cf,ds,level):
    log.info(' Opening the Excel file ')
    nRecs = len(ds.series['xlDateTime']['Data'])
    xlFileName = cf['Files'][level]['xlFilePath']+cf['Files'][level]['xlFileName']
    xlFile = xlwt.Workbook()
    if cf['General']['Platform'] == 'Mac':
        xlFile.dates_1904 = True
    xlDataSheet = xlFile.add_sheet('Data')
    xlFlagSheet = xlFile.add_sheet('Flag')
    xlCol = 0
    VariablesInFile = ds.series.keys()
    VariablesToOutput = ast.literal_eval(cf['Output'][level])
    # write the xl date/time value to the first column of the worksheets
    d_xf = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
    for j in range(nRecs):
        xlDataSheet.write(j+10,xlCol,ds.series['xlDateTime']['Data'][j],d_xf)
    xlFlagSheet.write(9,xlCol,'TIMESTAMP')
    xlDataSheet.write(9,xlCol,'TIMESTAMP')
    if not putils.cfkeycheck(cf,Base='Output',ThisOne='FlagDefs') or (putils.cfkeycheck(cf,Base='Output',ThisOne='FlagDefs') and cf['Output']['FlagDefs'] == 'True'):
        xlDataSheet.write(0,xlCol,'Site:')
        xlDataSheet.write(0,xlCol+1,ds.globalattributes['site'])
        xlDataSheet.write(2,xlCol,'Institution:')
        xlDataSheet.write(2,xlCol+1,ds.globalattributes['institution'])
        xlDataSheet.write(1,xlCol,'Latitude:')
        xlDataSheet.write(1,xlCol+1,ds.globalattributes['latitude'])
        xlDataSheet.write(1,xlCol+2,'Longitude:')
        xlDataSheet.write(1,xlCol+3,ds.globalattributes['longitude'])
        xlDataSheet.write(3,xlCol,'Contact:')
        xlDataSheet.write(3,xlCol+1,ds.globalattributes['contact'])
        xlFlagSheet.write(0,xlCol,'0:')
        xlFlagSheet.write(0,xlCol+1,ds.globalattributes['Flag000'])
        xlFlagSheet.write(0,xlCol+2,'1:')
        xlFlagSheet.write(0,xlCol+3,ds.globalattributes['Flag001'])
        xlFlagSheet.write(0,xlCol+4,'2:')
        xlFlagSheet.write(0,xlCol+5,ds.globalattributes['Flag002'])
        xlFlagSheet.write(0,xlCol+6,'3:')
        xlFlagSheet.write(0,xlCol+7,ds.globalattributes['Flag003'])
        xlFlagSheet.write(0,xlCol+8,'4:')
        xlFlagSheet.write(0,xlCol+9,ds.globalattributes['Flag004'])
        xlFlagSheet.write(0,xlCol+10,'5:')
        xlFlagSheet.write(0,xlCol+11,ds.globalattributes['Flag005'])
        xlFlagSheet.write(0,xlCol+12,'6:')
        xlFlagSheet.write(0,xlCol+13,ds.globalattributes['Flag006'])
        xlFlagSheet.write(0,xlCol+14,'7:')
        xlFlagSheet.write(0,xlCol+15,ds.globalattributes['Flag007'])
        xlFlagSheet.write(0,xlCol+16,'8:')
        xlFlagSheet.write(0,xlCol+17,ds.globalattributes['Flag008'])
        xlFlagSheet.write(0,xlCol+18,'9:')
        xlFlagSheet.write(0,xlCol+19,ds.globalattributes['Flag009'])
        xlFlagSheet.write(1,xlCol,'10:')
        xlFlagSheet.write(1,xlCol+1,ds.globalattributes['Flag010'])
        xlFlagSheet.write(1,xlCol+2,'11:')
        xlFlagSheet.write(1,xlCol+3,ds.globalattributes['Flag011'])
        xlFlagSheet.write(1,xlCol+4,'12:')
        xlFlagSheet.write(1,xlCol+5,ds.globalattributes['Flag012'])
        xlFlagSheet.write(1,xlCol+6,'13:')
        xlFlagSheet.write(1,xlCol+7,ds.globalattributes['Flag013'])
        xlFlagSheet.write(1,xlCol+8,'14:')
        xlFlagSheet.write(1,xlCol+9,ds.globalattributes['Flag014'])
        xlFlagSheet.write(1,xlCol+10,'15:')
        xlFlagSheet.write(1,xlCol+11,ds.globalattributes['Flag015'])
        xlFlagSheet.write(1,xlCol+12,'16:')
        xlFlagSheet.write(1,xlCol+13,ds.globalattributes['Flag016'])
        xlFlagSheet.write(1,xlCol+14,'17:')
        xlFlagSheet.write(1,xlCol+15,ds.globalattributes['Flag017'])
        xlFlagSheet.write(1,xlCol+16,'18:')
        xlFlagSheet.write(1,xlCol+17,ds.globalattributes['Flag018'])
        xlFlagSheet.write(1,xlCol+18,'19:')
        xlFlagSheet.write(1,xlCol+19,ds.globalattributes['Flag019'])
        xlFlagSheet.write(1,xlCol+20,'21:')
        xlFlagSheet.write(1,xlCol+21,ds.globalattributes['Flag021'])
        xlFlagSheet.write(1,xlCol+22,'22:')
        xlFlagSheet.write(1,xlCol+23,ds.globalattributes['Flag022'])
        xlFlagSheet.write(2,xlCol,'30:')
        xlFlagSheet.write(2,xlCol+1,ds.globalattributes['Flag030'])
        xlFlagSheet.write(2,xlCol+2,'31:')
        xlFlagSheet.write(2,xlCol+3,ds.globalattributes['Flag031'])
        xlFlagSheet.write(2,xlCol+4,'40:')
        xlFlagSheet.write(2,xlCol+5,ds.globalattributes['Flag040'])
        xlFlagSheet.write(2,xlCol+6,'50:')
        xlFlagSheet.write(2,xlCol+7,ds.globalattributes['Flag050'])
        xlFlagSheet.write(2,xlCol+8,'60:')
        xlFlagSheet.write(2,xlCol+9,ds.globalattributes['Flag060'])
        xlFlagSheet.write(2,xlCol+10,'70:')
        xlFlagSheet.write(2,xlCol+11,ds.globalattributes['Flag070'])
        xlFlagSheet.write(2,xlCol+12,'80:')
        xlFlagSheet.write(2,xlCol+13,ds.globalattributes['Flag080'])
        xlFlagSheet.write(2,xlCol+14,'81:')
        xlFlagSheet.write(2,xlCol+15,ds.globalattributes['Flag081'])
        xlFlagSheet.write(2,xlCol+16,'82:')
        xlFlagSheet.write(2,xlCol+17,ds.globalattributes['Flag082'])
        xlFlagSheet.write(2,xlCol+18,'83:')
        xlFlagSheet.write(2,xlCol+19,ds.globalattributes['Flag083'])
        xlFlagSheet.write(2,xlCol+20,'84:')
        xlFlagSheet.write(2,xlCol+21,ds.globalattributes['Flag084'])
        xlFlagSheet.write(2,xlCol+22,'85:')
        xlFlagSheet.write(2,xlCol+23,ds.globalattributes['Flag085'])
        xlFlagSheet.write(2,xlCol+24,'86:')
        xlFlagSheet.write(2,xlCol+25,ds.globalattributes['Flag086'])
        xlFlagSheet.write(2,xlCol+26,'87:')
        xlFlagSheet.write(2,xlCol+27,ds.globalattributes['Flag087'])
        xlFlagSheet.write(3,xlCol,'90:')
        xlFlagSheet.write(3,xlCol+1,ds.globalattributes['Flag090'])
        xlFlagSheet.write(3,xlCol+2,'100:')
        xlFlagSheet.write(3,xlCol+3,ds.globalattributes['Flag100'])
        xlFlagSheet.write(3,xlCol+4,'110:')
        xlFlagSheet.write(3,xlCol+5,ds.globalattributes['Flag110'])
        xlFlagSheet.write(3,xlCol+6,'120:')
        xlFlagSheet.write(3,xlCol+7,ds.globalattributes['Flag120'])
        xlFlagSheet.write(3,xlCol+8,'130:')
        xlFlagSheet.write(3,xlCol+9,ds.globalattributes['Flag130'])
        xlFlagSheet.write(3,xlCol+10,'140:')
        xlFlagSheet.write(3,xlCol+11,ds.globalattributes['Flag140'])
        xlFlagSheet.write(3,xlCol+12,'150:')
        xlFlagSheet.write(3,xlCol+13,ds.globalattributes['Flag150'])
        xlFlagSheet.write(3,xlCol+14,'151:')
        xlFlagSheet.write(3,xlCol+15,ds.globalattributes['Flag151'])
        xlFlagSheet.write(4,xlCol,'161:')
        xlFlagSheet.write(4,xlCol+1,ds.globalattributes['Flag161'])
        xlFlagSheet.write(4,xlCol+2,'162:')
        xlFlagSheet.write(4,xlCol+3,ds.globalattributes['Flag162'])
        xlFlagSheet.write(5,xlCol,'171:')
        xlFlagSheet.write(5,xlCol+1,ds.globalattributes['Flag171'])
        xlFlagSheet.write(5,xlCol+2,'173:')
        xlFlagSheet.write(5,xlCol+3,ds.globalattributes['Flag173'])
        xlFlagSheet.write(5,xlCol+4,'174:')
        xlFlagSheet.write(5,xlCol+5,ds.globalattributes['Flag174'])
        xlFlagSheet.write(5,xlCol+6,'180:')
        xlFlagSheet.write(5,xlCol+7,ds.globalattributes['Flag180'])
        xlFlagSheet.write(5,xlCol+8,'190:')
        xlFlagSheet.write(5,xlCol+9,ds.globalattributes['Flag190'])
        xlFlagSheet.write(5,xlCol+10,'191:')
        xlFlagSheet.write(5,xlCol+11,ds.globalattributes['Flag191'])
        xlFlagSheet.write(5,xlCol+12,'200:')
        xlFlagSheet.write(5,xlCol+13,ds.globalattributes['Flag200'])
        xlFlagSheet.write(5,xlCol+14,'201:')
        xlFlagSheet.write(5,xlCol+15,ds.globalattributes['Flag201'])
        xlFlagSheet.write(6,xlCol,'211:')
        xlFlagSheet.write(6,xlCol+1,ds.globalattributes['Flag211'])
    
    #d_xf = xlwt.easyxf('font: height 160',num_format_str='dd/mm/yyyy hh:mm')
    d_xf = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
    for j in range(nRecs):
        xlFlagSheet.write(j+10,xlCol,ds.series['xlDateTime']['Data'][j],d_xf)
    # remove the date and time variables from the list to output
    for ThisOne in ['xlDateTime','Year','Month','Day','Hour','Minute','Second','Hdh']:
        if ThisOne in VariablesInFile:
            VariablesInFile.remove(ThisOne)
    # now start looping over the other variables in the xl file
    xlCol = xlCol + 1
    # list of variables in the data structure
    #VariablesInFile.sort(key=str.lower)
    # list of variables to write out (specified in the control file)
    #VariablesToOutput.sort(key=str.lower)
    # loop over variables to be output to xl file
    for ThisOne in VariablesToOutput:
        if ThisOne in VariablesInFile:
            # put up a progress message
            log.info(' Writing '+ThisOne+' into column '+str(xlCol)+' of the Excel file')
            # specify the style of the output
            #d_xf = xlwt.easyxf('font: height 160')
            d_xf = xlwt.easyxf()
            # write the units and the variable name to the header rows in the xl file
            longname = ds.series[ThisOne]['Attr']['long_name']
            units = ds.series[ThisOne]['Attr']['units']
            #xlDataSheet.write(8,xlCol,Units,d_xf)
            #xlDataSheet.write(9,xlCol,ThisOne,d_xf)
            xlDataSheet.write(7,xlCol,longname)
            xlDataSheet.write(8,xlCol,units)
            xlDataSheet.write(9,xlCol,ThisOne)
            # loop over the values in the variable series (array writes don't seem to work)
            for j in range(nRecs):
                #xlDataSheet.write(j+10,xlCol,float(ds.series[ThisOne]['Data'][j]),d_xf)
                xlDataSheet.write(j+10,xlCol,float(ds.series[ThisOne]['Data'][j]))
            # check to see if this variable has a quality control flag
            if 'Flag' in ds.series[ThisOne].keys():
                # write the QC flag name to the xk file
                #xlFlagSheet.write(9,xlCol,ThisOne,d_xf)
                xlFlagSheet.write(9,xlCol,ThisOne)
                # specify the format of the QC flag (integer)
                #d_xf = xlwt.easyxf('font: height 160',num_format_str='0')
                d_xf = xlwt.easyxf(num_format_str='0')
                # loop over QV flag values and write to xl file
                for j in range(nRecs):
                    xlFlagSheet.write(j+10,xlCol,ds.series[ThisOne]['Flag'][j],d_xf)
            # increment the column pointer
            xlCol = xlCol + 1
    # tell the user what we are doing
    log.info(' Saving the Excel file '+xlFileName)
    # save the xl file
    xlFile.save(xlFileName)
Esempio n. 15
0
def xl_write_library(cf,ds,level):
    log.info(' Opening the Excel file ')
    xlfullname = cf['Files'][level]['xlFilePath']+cf['Files'][level]['xlFileName']
    xlfile = xlwt.Workbook()
    if putils.cfkeycheck(cf,Base='General',ThisOne='Platform') and cf['General']['Platform'] == 'Mac':
        xlfile.dates_1904 = True
    # add sheets to the Excel file
    xlAttrSheet = xlfile.add_sheet('Attr')
    xlDataSheet = xlfile.add_sheet('Data')
    xlFlagSheet = xlfile.add_sheet('Flag')
    # write the global attributes
    log.info(' Writing the global attributes to Excel file '+xlfullname)
    xlcol = 0
    xlrow = 0
    xlAttrSheet.write(xlrow,xlcol,'Global attributes')
    xlrow = xlrow + 1
    globalattrlist = ds.globalattributes.keys()
    globalattrlist.sort()
    for ThisOne in [x for x in globalattrlist if 'Flag' not in x]:
        xlAttrSheet.write(xlrow,xlcol,ThisOne)
        xlAttrSheet.write(xlrow,xlcol+1,str(ds.globalattributes[ThisOne]))
        xlrow = xlrow + 1
    for ThisOne in [x for x in globalattrlist if 'Flag' in x]:
        xlAttrSheet.write(xlrow,xlcol,ThisOne)
        xlAttrSheet.write(xlrow,xlcol+1,str(ds.globalattributes[ThisOne]))
        xlrow = xlrow + 1
    # write the variable attributes
    log.info(' Writing the variable attributes to Excel file '+xlfullname)
    xlrow = xlrow + 1
    xlAttrSheet.write(xlrow,xlcol,'Variable attributes')
    xlrow = xlrow + 1
    xlcol_varname = 0
    xlcol_attrname = 1
    xlcol_attrvalue = 2
    variablelist = ds.series.keys()
    variablelist.sort()
    if 'DateTime' in variablelist:
        variablelist.remove('DateTime')
    for ThisOne in variablelist:
        xlAttrSheet.write(xlrow,xlcol_varname,ThisOne)
        attributelist = ds.series[ThisOne]['Attr'].keys()
        attributelist.sort()
        for Attr in attributelist:
            xlAttrSheet.write(xlrow,xlcol_attrname,Attr)
            xlAttrSheet.write(xlrow,xlcol_attrvalue,ds.series[ThisOne]['Attr'][Attr])
            xlrow = xlrow + 1
    # write the Excel date/time to the data and the QC flags as the first column
    log.info(' Writing the datetime to Excel file '+xlfullname)
    nRecs = len(ds.series['xlDateTime']['Data'])
    d_xf = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
    xlDataSheet.write(2,xlcol,'xlDateTime')
    for j in range(nRecs):
        xlDataSheet.write(j+3,xlcol,ds.series['xlDateTime']['Data'][j],d_xf)
        xlFlagSheet.write(j+3,xlcol,ds.series['xlDateTime']['Data'][j],d_xf)
    # remove xlDateTime from the list of variables to be written to the Excel file
    variablelist.remove('xlDateTime')
    # now start looping over the other variables in the xl file
    xlcol = xlcol + 1
    # loop over variables to be output to xl file
    for ThisOne in variablelist:
        # put up a progress message
        log.info(' Writing '+ThisOne+' into column '+str(xlcol)+' of the Excel file')
        # write the units and the variable name to the header rows in the xl file
        attrlist = ds.series[ThisOne]['Attr'].keys()
        if 'long_name' in attrlist:
            longname = ds.series[ThisOne]['Attr']['long_name']
        elif 'Description' in attrlist:
            longname = ds.series[ThisOne]['Attr']['Description']
        else:
            longname = None
        if 'units' in attrlist:
            units = ds.series[ThisOne]['Attr']['units']
        elif 'Units' in attrlist:
            units = ds.series[ThisOne]['Attr']['Units']
        else:
            units = None
        xlDataSheet.write(0,xlcol,longname)
        xlDataSheet.write(1,xlcol,units)
        xlDataSheet.write(2,xlcol,ThisOne)
        # loop over the values in the variable series (array writes don't seem to work)
        for j in range(nRecs):
            xlDataSheet.write(j+3,xlcol,float(ds.series[ThisOne]['Data'][j]))
        # check to see if this variable has a quality control flag
        if 'Flag' in ds.series[ThisOne].keys():
            # write the QC flag name to the xk file
            xlFlagSheet.write(2,xlcol,ThisOne)
            # specify the format of the QC flag (integer)
            d_xf = xlwt.easyxf(num_format_str='0')
            # loop over QV flag values and write to xl file
            for j in range(nRecs):
                xlFlagSheet.write(j+3,xlcol,int(ds.series[ThisOne]['Flag'][j]),d_xf)
        # increment the column pointer
        xlcol = xlcol + 1
    
    log.info(' Saving the Excel file '+xlfullname)
    xlfile.save(xlfullname)
Esempio n. 16
0
def xl_write_library(cf, ds, level):
    log.info(' Opening the Excel file ')
    xlfullname = cf['Files'][level]['xlFilePath'] + cf['Files'][level][
        'xlFileName']
    xlfile = xlwt.Workbook()
    if putils.cfkeycheck(
            cf, Base='General',
            ThisOne='Platform') and cf['General']['Platform'] == 'Mac':
        xlfile.dates_1904 = True
    # add sheets to the Excel file
    xlAttrSheet = xlfile.add_sheet('Attr')
    xlDataSheet = xlfile.add_sheet('Data')
    xlFlagSheet = xlfile.add_sheet('Flag')
    # write the global attributes
    log.info(' Writing the global attributes to Excel file ' + xlfullname)
    xlcol = 0
    xlrow = 0
    xlAttrSheet.write(xlrow, xlcol, 'Global attributes')
    xlrow = xlrow + 1
    globalattrlist = ds.globalattributes.keys()
    globalattrlist.sort()
    for ThisOne in [x for x in globalattrlist if 'Flag' not in x]:
        xlAttrSheet.write(xlrow, xlcol, ThisOne)
        xlAttrSheet.write(xlrow, xlcol + 1, str(ds.globalattributes[ThisOne]))
        xlrow = xlrow + 1
    for ThisOne in [x for x in globalattrlist if 'Flag' in x]:
        xlAttrSheet.write(xlrow, xlcol, ThisOne)
        xlAttrSheet.write(xlrow, xlcol + 1, str(ds.globalattributes[ThisOne]))
        xlrow = xlrow + 1
    # write the variable attributes
    log.info(' Writing the variable attributes to Excel file ' + xlfullname)
    xlrow = xlrow + 1
    xlAttrSheet.write(xlrow, xlcol, 'Variable attributes')
    xlrow = xlrow + 1
    xlcol_varname = 0
    xlcol_attrname = 1
    xlcol_attrvalue = 2
    variablelist = ds.series.keys()
    variablelist.sort()
    if 'DateTime' in variablelist:
        variablelist.remove('DateTime')
    for ThisOne in variablelist:
        xlAttrSheet.write(xlrow, xlcol_varname, ThisOne)
        attributelist = ds.series[ThisOne]['Attr'].keys()
        attributelist.sort()
        for Attr in attributelist:
            xlAttrSheet.write(xlrow, xlcol_attrname, Attr)
            xlAttrSheet.write(xlrow, xlcol_attrvalue,
                              ds.series[ThisOne]['Attr'][Attr])
            xlrow = xlrow + 1
    # write the Excel date/time to the data and the QC flags as the first column
    log.info(' Writing the datetime to Excel file ' + xlfullname)
    nRecs = len(ds.series['xlDateTime']['Data'])
    d_xf = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
    xlDataSheet.write(2, xlcol, 'xlDateTime')
    for j in range(nRecs):
        xlDataSheet.write(j + 3, xlcol, ds.series['xlDateTime']['Data'][j],
                          d_xf)
        xlFlagSheet.write(j + 3, xlcol, ds.series['xlDateTime']['Data'][j],
                          d_xf)
    # remove xlDateTime from the list of variables to be written to the Excel file
    variablelist.remove('xlDateTime')
    # now start looping over the other variables in the xl file
    xlcol = xlcol + 1
    # loop over variables to be output to xl file
    for ThisOne in variablelist:
        # put up a progress message
        log.info(' Writing ' + ThisOne + ' into column ' + str(xlcol) +
                 ' of the Excel file')
        # write the units and the variable name to the header rows in the xl file
        attrlist = ds.series[ThisOne]['Attr'].keys()
        if 'long_name' in attrlist:
            longname = ds.series[ThisOne]['Attr']['long_name']
        elif 'Description' in attrlist:
            longname = ds.series[ThisOne]['Attr']['Description']
        else:
            longname = None
        if 'units' in attrlist:
            units = ds.series[ThisOne]['Attr']['units']
        elif 'Units' in attrlist:
            units = ds.series[ThisOne]['Attr']['Units']
        else:
            units = None
        xlDataSheet.write(0, xlcol, longname)
        xlDataSheet.write(1, xlcol, units)
        xlDataSheet.write(2, xlcol, ThisOne)
        # loop over the values in the variable series (array writes don't seem to work)
        for j in range(nRecs):
            xlDataSheet.write(j + 3, xlcol,
                              float(ds.series[ThisOne]['Data'][j]))
        # check to see if this variable has a quality control flag
        if 'Flag' in ds.series[ThisOne].keys():
            # write the QC flag name to the xk file
            xlFlagSheet.write(2, xlcol, ThisOne)
            # specify the format of the QC flag (integer)
            d_xf = xlwt.easyxf(num_format_str='0')
            # loop over QV flag values and write to xl file
            for j in range(nRecs):
                xlFlagSheet.write(j + 3, xlcol,
                                  int(ds.series[ThisOne]['Flag'][j]), d_xf)
        # increment the column pointer
        xlcol = xlcol + 1

    log.info(' Saving the Excel file ' + xlfullname)
    xlfile.save(xlfullname)
Esempio n. 17
0
def xl_write_series(cf, ds, level):
    log.info(' Opening the Excel file ')
    nRecs = len(ds.series['xlDateTime']['Data'])
    xlFileName = cf['Files'][level]['xlFilePath'] + cf['Files'][level][
        'xlFileName']
    xlFile = xlwt.Workbook()
    if cf['General']['Platform'] == 'Mac':
        xlFile.dates_1904 = True
    xlDataSheet = xlFile.add_sheet('Data')
    xlFlagSheet = xlFile.add_sheet('Flag')
    xlCol = 0
    VariablesInFile = ds.series.keys()
    VariablesToOutput = ast.literal_eval(cf['Output'][level])
    # write the xl date/time value to the first column of the worksheets
    d_xf = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
    for j in range(nRecs):
        xlDataSheet.write(j + 10, xlCol, ds.series['xlDateTime']['Data'][j],
                          d_xf)
    xlFlagSheet.write(9, xlCol, 'TIMESTAMP')
    xlDataSheet.write(9, xlCol, 'TIMESTAMP')
    if not putils.cfkeycheck(cf, Base='Output', ThisOne='FlagDefs') or (
            putils.cfkeycheck(cf, Base='Output', ThisOne='FlagDefs')
            and cf['Output']['FlagDefs'] == 'True'):
        xlDataSheet.write(0, xlCol, 'Site:')
        xlDataSheet.write(0, xlCol + 1, ds.globalattributes['site'])
        xlDataSheet.write(2, xlCol, 'Institution:')
        xlDataSheet.write(2, xlCol + 1, ds.globalattributes['institution'])
        xlDataSheet.write(1, xlCol, 'Latitude:')
        xlDataSheet.write(1, xlCol + 1, ds.globalattributes['latitude'])
        xlDataSheet.write(1, xlCol + 2, 'Longitude:')
        xlDataSheet.write(1, xlCol + 3, ds.globalattributes['longitude'])
        xlDataSheet.write(3, xlCol, 'Contact:')
        xlDataSheet.write(3, xlCol + 1, ds.globalattributes['contact'])
        xlFlagSheet.write(0, xlCol, '0:')
        xlFlagSheet.write(0, xlCol + 1, ds.globalattributes['Flag000'])
        xlFlagSheet.write(0, xlCol + 2, '1:')
        xlFlagSheet.write(0, xlCol + 3, ds.globalattributes['Flag001'])
        xlFlagSheet.write(0, xlCol + 4, '2:')
        xlFlagSheet.write(0, xlCol + 5, ds.globalattributes['Flag002'])
        xlFlagSheet.write(0, xlCol + 6, '3:')
        xlFlagSheet.write(0, xlCol + 7, ds.globalattributes['Flag003'])
        xlFlagSheet.write(0, xlCol + 8, '4:')
        xlFlagSheet.write(0, xlCol + 9, ds.globalattributes['Flag004'])
        xlFlagSheet.write(0, xlCol + 10, '5:')
        xlFlagSheet.write(0, xlCol + 11, ds.globalattributes['Flag005'])
        xlFlagSheet.write(0, xlCol + 12, '6:')
        xlFlagSheet.write(0, xlCol + 13, ds.globalattributes['Flag006'])
        xlFlagSheet.write(0, xlCol + 14, '7:')
        xlFlagSheet.write(0, xlCol + 15, ds.globalattributes['Flag007'])
        xlFlagSheet.write(0, xlCol + 16, '8:')
        xlFlagSheet.write(0, xlCol + 17, ds.globalattributes['Flag008'])
        xlFlagSheet.write(0, xlCol + 18, '9:')
        xlFlagSheet.write(0, xlCol + 19, ds.globalattributes['Flag009'])
        xlFlagSheet.write(1, xlCol, '10:')
        xlFlagSheet.write(1, xlCol + 1, ds.globalattributes['Flag010'])
        xlFlagSheet.write(1, xlCol + 2, '11:')
        xlFlagSheet.write(1, xlCol + 3, ds.globalattributes['Flag011'])
        xlFlagSheet.write(1, xlCol + 4, '12:')
        xlFlagSheet.write(1, xlCol + 5, ds.globalattributes['Flag012'])
        xlFlagSheet.write(1, xlCol + 6, '13:')
        xlFlagSheet.write(1, xlCol + 7, ds.globalattributes['Flag013'])
        xlFlagSheet.write(1, xlCol + 8, '14:')
        xlFlagSheet.write(1, xlCol + 9, ds.globalattributes['Flag014'])
        xlFlagSheet.write(1, xlCol + 10, '15:')
        xlFlagSheet.write(1, xlCol + 11, ds.globalattributes['Flag015'])
        xlFlagSheet.write(1, xlCol + 12, '16:')
        xlFlagSheet.write(1, xlCol + 13, ds.globalattributes['Flag016'])
        xlFlagSheet.write(1, xlCol + 14, '17:')
        xlFlagSheet.write(1, xlCol + 15, ds.globalattributes['Flag017'])
        xlFlagSheet.write(1, xlCol + 16, '18:')
        xlFlagSheet.write(1, xlCol + 17, ds.globalattributes['Flag018'])
        xlFlagSheet.write(1, xlCol + 18, '19:')
        xlFlagSheet.write(1, xlCol + 19, ds.globalattributes['Flag019'])
        xlFlagSheet.write(1, xlCol + 20, '21:')
        xlFlagSheet.write(1, xlCol + 21, ds.globalattributes['Flag021'])
        xlFlagSheet.write(1, xlCol + 22, '22:')
        xlFlagSheet.write(1, xlCol + 23, ds.globalattributes['Flag022'])
        xlFlagSheet.write(2, xlCol, '30:')
        xlFlagSheet.write(2, xlCol + 1, ds.globalattributes['Flag030'])
        xlFlagSheet.write(2, xlCol + 2, '31:')
        xlFlagSheet.write(2, xlCol + 3, ds.globalattributes['Flag031'])
        xlFlagSheet.write(2, xlCol + 4, '40:')
        xlFlagSheet.write(2, xlCol + 5, ds.globalattributes['Flag040'])
        xlFlagSheet.write(2, xlCol + 6, '50:')
        xlFlagSheet.write(2, xlCol + 7, ds.globalattributes['Flag050'])
        xlFlagSheet.write(2, xlCol + 8, '60:')
        xlFlagSheet.write(2, xlCol + 9, ds.globalattributes['Flag060'])
        xlFlagSheet.write(2, xlCol + 10, '70:')
        xlFlagSheet.write(2, xlCol + 11, ds.globalattributes['Flag070'])
        xlFlagSheet.write(2, xlCol + 12, '80:')
        xlFlagSheet.write(2, xlCol + 13, ds.globalattributes['Flag080'])
        xlFlagSheet.write(2, xlCol + 14, '81:')
        xlFlagSheet.write(2, xlCol + 15, ds.globalattributes['Flag081'])
        xlFlagSheet.write(2, xlCol + 16, '82:')
        xlFlagSheet.write(2, xlCol + 17, ds.globalattributes['Flag082'])
        xlFlagSheet.write(2, xlCol + 18, '83:')
        xlFlagSheet.write(2, xlCol + 19, ds.globalattributes['Flag083'])
        xlFlagSheet.write(2, xlCol + 20, '84:')
        xlFlagSheet.write(2, xlCol + 21, ds.globalattributes['Flag084'])
        xlFlagSheet.write(2, xlCol + 22, '85:')
        xlFlagSheet.write(2, xlCol + 23, ds.globalattributes['Flag085'])
        xlFlagSheet.write(2, xlCol + 24, '86:')
        xlFlagSheet.write(2, xlCol + 25, ds.globalattributes['Flag086'])
        xlFlagSheet.write(2, xlCol + 26, '87:')
        xlFlagSheet.write(2, xlCol + 27, ds.globalattributes['Flag087'])
        xlFlagSheet.write(3, xlCol, '90:')
        xlFlagSheet.write(3, xlCol + 1, ds.globalattributes['Flag090'])
        xlFlagSheet.write(3, xlCol + 2, '100:')
        xlFlagSheet.write(3, xlCol + 3, ds.globalattributes['Flag100'])
        xlFlagSheet.write(3, xlCol + 4, '110:')
        xlFlagSheet.write(3, xlCol + 5, ds.globalattributes['Flag110'])
        xlFlagSheet.write(3, xlCol + 6, '120:')
        xlFlagSheet.write(3, xlCol + 7, ds.globalattributes['Flag120'])
        xlFlagSheet.write(3, xlCol + 8, '130:')
        xlFlagSheet.write(3, xlCol + 9, ds.globalattributes['Flag130'])
        xlFlagSheet.write(3, xlCol + 10, '140:')
        xlFlagSheet.write(3, xlCol + 11, ds.globalattributes['Flag140'])
        xlFlagSheet.write(3, xlCol + 12, '150:')
        xlFlagSheet.write(3, xlCol + 13, ds.globalattributes['Flag150'])
        xlFlagSheet.write(3, xlCol + 14, '151:')
        xlFlagSheet.write(3, xlCol + 15, ds.globalattributes['Flag151'])
        xlFlagSheet.write(4, xlCol, '161:')
        xlFlagSheet.write(4, xlCol + 1, ds.globalattributes['Flag161'])
        xlFlagSheet.write(4, xlCol + 2, '162:')
        xlFlagSheet.write(4, xlCol + 3, ds.globalattributes['Flag162'])
        xlFlagSheet.write(5, xlCol, '171:')
        xlFlagSheet.write(5, xlCol + 1, ds.globalattributes['Flag171'])
        xlFlagSheet.write(5, xlCol + 2, '173:')
        xlFlagSheet.write(5, xlCol + 3, ds.globalattributes['Flag173'])
        xlFlagSheet.write(5, xlCol + 4, '174:')
        xlFlagSheet.write(5, xlCol + 5, ds.globalattributes['Flag174'])
        xlFlagSheet.write(5, xlCol + 6, '180:')
        xlFlagSheet.write(5, xlCol + 7, ds.globalattributes['Flag180'])
        xlFlagSheet.write(5, xlCol + 8, '190:')
        xlFlagSheet.write(5, xlCol + 9, ds.globalattributes['Flag190'])
        xlFlagSheet.write(5, xlCol + 10, '191:')
        xlFlagSheet.write(5, xlCol + 11, ds.globalattributes['Flag191'])
        xlFlagSheet.write(5, xlCol + 12, '200:')
        xlFlagSheet.write(5, xlCol + 13, ds.globalattributes['Flag200'])
        xlFlagSheet.write(5, xlCol + 14, '201:')
        xlFlagSheet.write(5, xlCol + 15, ds.globalattributes['Flag201'])
        xlFlagSheet.write(6, xlCol, '211:')
        xlFlagSheet.write(6, xlCol + 1, ds.globalattributes['Flag211'])

    #d_xf = xlwt.easyxf('font: height 160',num_format_str='dd/mm/yyyy hh:mm')
    d_xf = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
    for j in range(nRecs):
        xlFlagSheet.write(j + 10, xlCol, ds.series['xlDateTime']['Data'][j],
                          d_xf)
    # remove the date and time variables from the list to output
    for ThisOne in [
            'xlDateTime', 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second',
            'Hdh'
    ]:
        if ThisOne in VariablesInFile:
            VariablesInFile.remove(ThisOne)
    # now start looping over the other variables in the xl file
    xlCol = xlCol + 1
    # list of variables in the data structure
    #VariablesInFile.sort(key=str.lower)
    # list of variables to write out (specified in the control file)
    #VariablesToOutput.sort(key=str.lower)
    # loop over variables to be output to xl file
    for ThisOne in VariablesToOutput:
        if ThisOne in VariablesInFile:
            # put up a progress message
            log.info(' Writing ' + ThisOne + ' into column ' + str(xlCol) +
                     ' of the Excel file')
            # specify the style of the output
            #d_xf = xlwt.easyxf('font: height 160')
            d_xf = xlwt.easyxf()
            # write the units and the variable name to the header rows in the xl file
            longname = ds.series[ThisOne]['Attr']['long_name']
            units = ds.series[ThisOne]['Attr']['units']
            #xlDataSheet.write(8,xlCol,Units,d_xf)
            #xlDataSheet.write(9,xlCol,ThisOne,d_xf)
            xlDataSheet.write(7, xlCol, longname)
            xlDataSheet.write(8, xlCol, units)
            xlDataSheet.write(9, xlCol, ThisOne)
            # loop over the values in the variable series (array writes don't seem to work)
            for j in range(nRecs):
                #xlDataSheet.write(j+10,xlCol,float(ds.series[ThisOne]['Data'][j]),d_xf)
                xlDataSheet.write(j + 10, xlCol,
                                  float(ds.series[ThisOne]['Data'][j]))
            # check to see if this variable has a quality control flag
            if 'Flag' in ds.series[ThisOne].keys():
                # write the QC flag name to the xk file
                #xlFlagSheet.write(9,xlCol,ThisOne,d_xf)
                xlFlagSheet.write(9, xlCol, ThisOne)
                # specify the format of the QC flag (integer)
                #d_xf = xlwt.easyxf('font: height 160',num_format_str='0')
                d_xf = xlwt.easyxf(num_format_str='0')
                # loop over QV flag values and write to xl file
                for j in range(nRecs):
                    xlFlagSheet.write(j + 10, xlCol,
                                      ds.series[ThisOne]['Flag'][j], d_xf)
            # increment the column pointer
            xlCol = xlCol + 1
    # tell the user what we are doing
    log.info(' Saving the Excel file ' + xlFileName)
    # save the xl file
    xlFile.save(xlFileName)