- Timestamp:
- Mar 10, 2015, 11:21:17 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/validation_sim.py
r344 r346 1020 1020 gstatsn = ['bias', 'simobs_mean', 'sim_obsmin', 'sim_obsmax', 'sim_obsmean', 'mae', \ 1021 1021 'rmse', 'r_pearsoncorr', 'p_pearsoncorr'] 1022 ostatsn = ['number of points', ' start', 'end', 'minimum', 'maximum', 'mean',\1023 ' mean2', 'standard deviation']1022 ostatsn = ['number of points', 'minimum', 'maximum', 'mean', 'mean2', \ 1023 'standard deviation'] 1024 1024 1025 1025 parser = OptionParser() … … 1333 1333 # Dimensions 1334 1334 newdim = onewnc.createDimension('time',None) 1335 newdim = onewnc.createDimension('bnds',2) 1335 1336 newdim = onewnc.createDimension('obstime',None) 1336 1337 newdim = onewnc.createDimension('couple',2) … … 1340 1341 newdim = onewnc.createDimension('gstats',9) 1341 1342 newdim = onewnc.createDimension('stats',5) 1342 newdim = onewnc.createDimension('tstats', 8)1343 newdim = onewnc.createDimension('tstats',6) 1343 1344 1344 1345 # Variable dimensions … … 1347 1348 basicvardef(newvar, 'obstime', 'time observations', obstunits ) 1348 1349 set_attribute(newvar, 'calendar', 'standard') 1350 set_attribute(newvar, 'bounds', 'time_bnds') 1349 1351 newvar[:] = coindtvalues[:,3] 1350 1352 … … 1608 1610 1609 1611 # Statistics around obs values 1610 aroundostats = np.zeros(( 8,Ncoindt), dtype=np.float)1612 aroundostats = np.zeros((6,Ncoindt), dtype=np.float) 1611 1613 1612 1614 for it in range(Ncoindt): … … 1615 1617 1616 1618 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'), \ 1628 1628 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] 1633 1639 1634 1640 # Around values … … 1682 1688 newvar[:] = aroundstats.transpose() 1683 1689 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 1684 1696 # around obs Statistics 1685 1697 if not searchInlist(onewnc.variables,valvars[ivar][1] + 'staround'): … … 1689 1701 basicvardef(newvar, valvars[ivar][1] + 'staround', descvar, \ 1690 1702 ovobs.getncattr('units')) 1703 set_attribute(newvar, 'cell_methods', 'statistics') 1704 1691 1705 newvar[:] = aroundostats.transpose() 1692 1706
Note: See TracChangeset
for help on using the changeset viewer.