Changeset 1848 in lmdz_wrf
- Timestamp:
- Mar 23, 2018, 2:48:42 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r1847 r1848 22690 22690 [globattrfilen]: name of ASCII file with the given metadata to be added as global attributes 22691 22691 with a line per attribute [attrname] [value] it has to have at least (underparenthesis for description) 22692 use '#' for comments :22692 use '#' for comments (use '[unknown]' for that values set-up according to content from file: 22693 22693 institute_id [value, use '!' for spaces] (CV) 22694 22694 institution [value] … … 22699 22699 product [value] (single value: "output") 22700 22700 Conventions [value] (later than CF1.4 if present / single value: "CF-1.4") 22701 creation_date [ YYYY-MM-DDTHH:MM:SSZ] (format according to UNIDATA conventions, same in CMIP5 & CORDEX)22701 creation_date [value] ([YYYY-MM-DDTHH:MM:SSZ] format according to UNIDATA conventions, same in CMIP5 & CORDEX) 22702 22702 frequency [value] (same CV as CMIP5 with "sem" in addition; 3hr highest freq. in CORDEX; no "yr") 22703 22703 driving_model_id [value] (CMIP5 institute_id, <CMIP5 institute_id>-<member in CMIP5 CV list of model_id>) … … 22726 22726 NOTE: CF values will be taken from 'variables_values.dat' 22727 22727 """ 22728 import datetime as dt 22728 22729 fname = 'CFmorzization' 22729 22730 … … 22926 22927 'Y-m-dTH:M:SZ') 22927 22928 secfreq = gen.CFtime_freq(axisv[0], axisv[1], tunits) 22929 Sfreq = -1 22928 22930 # Labelling frequency 22929 22931 if np.mod(secfreq, 100 * 365 * 24 * 3600.) == 0.: 22930 22932 Sfreq = str(int(secfreq/(100 * 365 * 24 * 3600.))) + 'C' 22931 elif np.mod(secfreq, 365 * 24 * 3600.) == 0.:22933 elif Sfreq == -1 and np.mod(secfreq, 365 * 24 * 3600.) == 0.: 22932 22934 Sfreq = str(int(secfreq/(365 * 24 * 3600.))) + 'Y' 22933 elif np.mod(secfreq, 7 * 24 * 3600.) == 0.:22935 elif Sfreq == -1 and np.mod(secfreq, 7 * 24 * 3600.) == 0.: 22934 22936 Sfreq = str(int(secfreq/(7 * 24 * 3600.))) + 'W' 22935 elif np.mod(secfreq, 24 * 3600.) == 0.:22937 elif Sfreq == -1 and np.mod(secfreq, 24 * 3600.) == 0.: 22936 22938 Sfreq = str(int(secfreq/(24.*3600.))) + 'D' 22937 elif np.mod(secfreq,3600.) == 0.:22939 elif Sfreq == -1 and np.mod(secfreq,3600.) == 0.: 22938 22940 Sfreq = str(int(secfreq/3600.)) + 'H' 22939 elif np.mod(secfreq,60.) == 0.:22941 elif Sfreq == -1 and np.mod(secfreq,60.) == 0.: 22940 22942 Sfreq = str(int(secfreq/60.)) + 'M' 22941 else: Sfreq = 'UNKNOWN' 22943 else: 22944 # Getting frequency from the global attributes 22945 Sfreq = gattr['frequency'] 22946 if gattr['frequency'] == '[unknown]': gattr['frequency'] = Sfreq 22947 print ' frquency in file:', secfreq, 's', Sfreq 22948 22949 # Renaming dimensions for 2D lon,lat variable-dimensions 22950 if len(filedimvals['X'].shape) == 2 or len(filedimvals['Y'].shape) == 2: 22951 print infmsg 22952 print ' because Xvals have rank 2:', filedimvals['X'].shape, \ 22953 'renaming lon,lat dimensions to x,y' 22954 axv = CFdimvals['X'] 22955 axv['dimn'] = 'x' 22956 CFdimvals['X'] = axv 22957 axv = CFdimvals['Y'] 22958 axv['dimn'] = 'y' 22959 CFdimvals['Y'] = axv 22960 #axiv = axisinf['X'] 22961 #filecfdimn[axiv[0]] = 'x' 22962 #axiv = axisinf['Y'] 22963 #filecfdimn[axiv[0]] = 'y' 22942 22964 22943 22965 print 'Values for variables-axes from file ________' … … 22968 22990 22969 22991 CFaxisvardimvals[axn] = cfdimaxes 22992 22970 22993 print 'file --> CF equivalencies of dimensions _______' 22971 22994 print filecfdimn … … 23013 23036 '_' + gattr['rcm_version_id'] + '_' + Sfreq + '_' + Sinit + '-' + Sendt + \ 23014 23037 '.nc' 23015 23016 23038 onewnc = NetCDFFile(filen,'w') 23039 now = dt.datetime.now() 23040 if gattr['creation_date'] == '[unknown]': 23041 gattr['creation_date'] = now.strftime("%Y-%m-%dT%H:%M:%SZ") 23017 23042 # Definition only of that coordinates from the variable 23018 23043 for axn in varaxes:
Note: See TracChangeset
for help on using the changeset viewer.