- Timestamp:
- Sep 9, 2016, 5:31:47 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r1083 r1088 16737 16737 return 16738 16738 16739 def LMDZ_toCF( ncfile):16739 def LMDZ_toCF(values,ncfile): 16740 16740 """ Function to pass a LMDZ original file to CF-conventions 16741 values= [CFtimeUnits] 16742 [CFtimeUnits]: [tunits] since [YYYYMMDDHHMISS], CF time-units to which variable time should be used ('!' for spaces) 16741 16743 ncfile= file to transform 16742 variables= variables to transform16743 16744 """ 16744 16745 fname = 'LMDZ_toCF' … … 16748 16749 print LMDZ_toCF.__doc__ 16749 16750 quit() 16751 16752 CFT = values.replace('!',' ') 16750 16753 16751 16754 ofile = 'CF_LMDZ.nc' … … 16760 16763 print fname + ": renaming variable 'pres' as 'p' !!" 16761 16764 newname = ncf.renameVariable('pres','p') 16765 ncf.sync() 16766 16767 # Re-aranging time-axis 16768 tvaro = ncf.variables['time_counter'] 16769 tvals = tvaro[:] 16770 tunits = tvaro.getncattr('units') 16771 16772 RefDate = CFT.split(' ')[2] 16773 RefDateS = RefDate[0:4] + '-' + RefDate[4:6] + '-' + RefDate[6:8] + ' ' + \ 16774 RefDate[8:10] + ':' + RefDate[10:12] + ':' + RefDate[12:14] 16775 CFtimeUnits = ' '.join(CFT.split(' ')[0:2]) + ' '+ RefDateS 16776 16777 newtvals = gen.coincident_CFtimes(tvals, CFtimeUnits, tunits) 16778 tvaro[:] = newtvals 16779 newattr = set_attribute(tvaro, 'units', CFtimeUnits) 16780 newattr = set_attribute(tvaro, 'time_origin', CFtimeUnits) 16781 16762 16782 ncf.sync() 16763 16783
Note: See TracChangeset
for help on using the changeset viewer.