Changeset 346 in lmdz_wrf


Ignore:
Timestamp:
Mar 10, 2015, 11:21:17 AM (10 years ago)
Author:
lfita
Message:

Splitting simulated and observed variables
Adding time_bnds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/validation_sim.py

    r344 r346  
    10201020gstatsn = ['bias', 'simobs_mean', 'sim_obsmin', 'sim_obsmax', 'sim_obsmean', 'mae',  \
    10211021  'rmse', 'r_pearsoncorr', 'p_pearsoncorr']
    1022 ostatsn = ['number of points', 'start', 'end', 'minimum', 'maximum', 'mean',         \
    1023   'mean2', 'standard deviation']
     1022ostatsn = ['number of points', 'minimum', 'maximum', 'mean', 'mean2',                \
     1023  'standard deviation']
    10241024
    10251025parser = OptionParser()
     
    13331333# Dimensions
    13341334newdim = onewnc.createDimension('time',None)
     1335newdim = onewnc.createDimension('bnds',2)
    13351336newdim = onewnc.createDimension('obstime',None)
    13361337newdim = onewnc.createDimension('couple',2)
     
    13401341newdim = onewnc.createDimension('gstats',9)
    13411342newdim = onewnc.createDimension('stats',5)
    1342 newdim = onewnc.createDimension('tstats',8)
     1343newdim = onewnc.createDimension('tstats',6)
    13431344
    13441345# Variable dimensions
     
    13471348basicvardef(newvar, 'obstime', 'time observations', obstunits )
    13481349set_attribute(newvar, 'calendar', 'standard')
     1350set_attribute(newvar, 'bounds', 'time_bnds')
    13491351newvar[:] = coindtvalues[:,3]
    13501352
     
    16081610
    16091611# Statistics around obs values
    1610     aroundostats = np.zeros((8,Ncoindt), dtype=np.float)
     1612    aroundostats = np.zeros((6,Ncoindt), dtype=np.float)
    16111613
    16121614    for it in range(Ncoindt):
     
    16151617
    16161618        aroundostats[0,it] = len(obsmask.flatten())
    1617         aroundostats[1,it] = simobsTtvalues[it,0]
    1618         aroundostats[2,it] = simobsTtvalues[it,1]
    1619         aroundostats[3,it] = obsmask.min()
    1620         aroundostats[4,it] = obsmask.max()
    1621         aroundostats[5,it] = obsmask.mean()
    1622         aroundostats[6,it] = obsmask2.mean()
    1623         aroundostats[7,it] = np.sqrt(aroundostats[6,it] - aroundostats[5,it]*        \
    1624           aroundostats[5,it])
    1625 
    1626 # Values to netCDF
    1627     newvar = onewnc.createVariable(varsimobs, 'f', ('time','couple'),                \
     1619        aroundostats[1,it] = obsmask.min()
     1620        aroundostats[2,it] = obsmask.max()
     1621        aroundostats[3,it] = obsmask.mean()
     1622        aroundostats[4,it] = obsmask2.mean()
     1623        aroundostats[5,it] = np.sqrt(aroundostats[4,it] - aroundostats[3,it]*        \
     1624          aroundostats[3,it])
     1625
     1626# sim Values to netCDF
     1627    newvar = onewnc.createVariable(valvars[ivar][0], 'f', ('time'),                  \
    16281628      fill_value=fillValueF)
    1629     descvar = 'couples of simulated: ' + valvars[ivar][0] + ' and observed ' +       \
    1630       valvars[ivar][1]
    1631     basicvardef(newvar, varsimobs, descvar, ovobs.getncattr('units'))
    1632     newvar[:] = arrayvals
     1629    descvar = 'simulated: ' + valvars[ivar][0]
     1630    basicvardef(newvar, valvars[ivar][0], descvar, ovobs.getncattr('units'))
     1631    newvar[:] = arrayvals[:,0]
     1632
     1633# obs Values to netCDF
     1634    newvar = onewnc.createVariable(valvars[ivar][1], 'f', ('time'),                  \
     1635      fill_value=fillValueF)
     1636    descvar = 'observed: ' + valvars[ivar][1]
     1637    basicvardef(newvar, valvars[ivar][1], descvar, ovobs.getncattr('units'))
     1638    newvar[:] = arrayvals[:,1]
    16331639
    16341640# Around values
     
    16821688        newvar[:] = aroundstats.transpose()
    16831689
     1690    if not searchInlist(onewnc.variables, 'time_bnds'):
     1691        newvar = onewnc.createVariable('time_bnds','f8',('time','bnds'))
     1692        basicvardef(newvar, 'time_bnds', 'time', obstunits )
     1693        set_attribute(newvar, 'calendar', 'standard')
     1694        newvar[:] = simobsTtvalues
     1695
    16841696# around obs Statistics
    16851697    if not searchInlist(onewnc.variables,valvars[ivar][1] + 'staround'):
     
    16891701        basicvardef(newvar, valvars[ivar][1] + 'staround', descvar,                  \
    16901702          ovobs.getncattr('units'))
     1703        set_attribute(newvar, 'cell_methods', 'statistics')
     1704
    16911705        newvar[:] = aroundostats.transpose()
    16921706
Note: See TracChangeset for help on using the changeset viewer.