Changeset 1843 in lmdz_wrf
- Timestamp:
- Mar 22, 2018, 8:28:48 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1842 r1843 57 57 # CFcorValues: Function to provide CF information about a given coordinate 58 58 # CFmonthU_daysU: Function to transform from a CF date series with units as 'months since [DATE]' to 'days since [DATE]' 59 # CFtime_freq: Function to provide the frequency of CF times (in seconds) 59 60 # CFvar_DIAGvar: Function to provide which model diagnostic values can provide a CF-variable from ASCII file 60 61 # CFvar_MODvar: Function to provide which model values can provide a CF-variable from ASCII file … … 664 665 str(da).zfill(2) + ' ' + str(ho).zfill(2) + '-' + str(mi).zfill(2) + '-' + \ 665 666 str(se).zfill(2) 666 elif typeSo = 'Y-m-dTH:M:SZ':667 elif typeSo == 'Y-m-dTH:M:SZ': 667 668 dateYmdHMS = str(yr).zfill(4) + '-' + str(mo).zfill(2) + '-' + \ 668 669 str(da).zfill(2) + 'T' + str(ho).zfill(2) + ':' + str(mi).zfill(2) + ':' + \ … … 12700 12701 # Dictionary for each dimension 12701 12702 CFlon= {'dimn': 'lon', 'stdn': 'longitude', 'longname': 'Longitude', 'units': \ 12702 'degrees_east', 'axis': 'X', '_CoordinateAxisType': 'Lon', 'maxrank :', 2,\12703 'degrees_east', 'axis': 'X', '_CoordinateAxisType': 'Lon', 'maxrank': 2, \ 12703 12704 'length': 0} 12704 12705 CFlat= {'dimn': 'lat', 'stdn': 'latitude', 'longname': 'Latitude', 'units': \ 12705 'degrees_north', 'axis': 'Y', '_CoordinateAxisType': 'Lat', 'maxrank :',2, \12706 'degrees_north', 'axis': 'Y', '_CoordinateAxisType': 'Lat', 'maxrank': 2, \ 12706 12707 'length': 0} 12707 12708 CFpress= {'dimn': 'pressure', 'stdn': 'pressure', 'longname': 'Pressure', \ 12708 12709 'units': 'Pa', 'axis': 'Z', '_CoordinateAxisType': 'Pres', 'positive': 'down', \ 12709 'maxrank :',1, 'length': 0}12710 'maxrank': 1, 'length': 0} 12710 12711 CFheight= {'dimn': 'height', 'stdn': 'height', 'longname': 'Height', \ 12711 12712 'units': 'm', 'axis': 'Z', '_CoordinateAxisType': 'Height', 'positive': 'up', \ 12712 'maxrank :',1, 'length': 0}12713 'maxrank': 1, 'length': 0} 12713 12714 CFtime= {'dimn': 'time', 'stdn': 'time', 'longname': 'Time', \ 12714 12715 'units': '[t] since [date]', 'axis': 'T', '_CoordinateAxisType': 'Time', \ 12715 'calendar': '[calendar]', 'maxrank :',1, 'length': -1}12716 'calendar': '[calendar]', 'maxrank': 1, 'length': -1} 12716 12717 12717 12718 # names to search for … … 12744 12745 return cdfim 12745 12746 12747 def CFtime_freq(time1, time2, tunits): 12748 """ Function to provide the frequency of CF times (in seconds) 12749 time1: time-step value 12750 time2: following time-step value 12751 tunits: time untis following CF conventions 12752 >>> CFtime_freq(521438., 521439., 'hours since 1950-01-01_00:00:00') 12753 3600.0 12754 """ 12755 fname = 'CFtime_freq' 12756 12757 timediff = time2 - time1 12758 12759 tunitsval = tunits.split(' ')[0] 12760 12761 # Units for the variable 'time' to seconds 12762 availtunitvals = ['centuries', 'years', 'days', 'hours', 'minutes', 'seconds'] 12763 if tunitsval == 'centuries': 12764 tsecsuv = 100 * 365 * 24 * 3600. 12765 elif tunitsval == 'years': 12766 tsecsuv = 365 * 24 * 3600. 12767 elif tunitsval == 'weeks': 12768 tsecsuv = 7 * 24 * 3600. 12769 elif tunitsval == 'days': 12770 tsecsuv = 24 * 3600. 12771 elif tunitsval == 'hours': 12772 tsecsuv = 3600. 12773 elif tunitsval == 'minutes': 12774 tsecsuv = 60. 12775 elif tunitsval == 'seconds': 12776 tsecsuv = 1. 12777 else: 12778 print errormsg 12779 print ' ' + fname + ":' tunitsvals= '" + tunitsval + "' not ready!!" 12780 print ' available ones: ', availtunitvals 12781 quit(-1) 12782 12783 freq = timediff*tsecsuv 12784 12785 return freq 12786 #print CFtime_freq(521438., 521439., 'hours since 1950-01-01_00:00:00') 12787 12746 12788 #quit() 12747 12789
Note: See TracChangeset
for help on using the changeset viewer.