Changeset 507 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 17, 2015, 3:09:46 PM (10 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var.py
r418 r507 22 22 'chgtimestep', 'chvarname', 'compute_deaccum', 'compute_opersvarsfiles', \ 23 23 'compute_opervaralltime', 'compute_opervartimes', 'compute_tevolboxtraj', \ 24 'DatesFiles', \ 24 25 'DataSetSection', 'DataSetSection_multidims', 'dimToUnlimited', 'dimVar_creation', \ 25 26 'fattradd', \ … … 127 128 elif oper == 'DataSetSection_multidims': 128 129 ncvar.DataSetSection_multidims(opts.values, opts.ncfile) 130 elif oper == 'DatesFiles': 131 ncvar.DatesFiles(opts.values, opts.ncfile, opts.varname) 129 132 elif oper == 'dimToUnlimited': 130 133 ncvar.dimToUnlimited(opts.values, opts.ncfile) -
trunk/tools/nc_var_tools.py
r490 r507 15866 15866 return 15867 15867 15868 def DatesFiles(values, ncfile, varn): 15869 """ Function to find different time values on a series of WRF files in a folder 15870 [values]= [dates],[folder] 15871 [dates]: ':' list of [YYYY][MM][DD][HH][MI][SS] dates 15872 [fold]: folder with the location of the netCDF files 15873 [ncfile]= header of the name of the files to concatenate [ncfile]* 15874 [varn]= name of the variable Time ('WRFt', for WRF time) 15875 """ 15876 import subprocess as sub 15877 fname='DatesFiles' 15878 15879 if values == 'h': 15880 print fname + '_____________________________________________________________' 15881 print DatesFiles.__doc__ 15882 quit() 15883 15884 arguments = '[dates],[fold]' 15885 check_arguments(fname, len(values.split(',')), arguments, ',', \ 15886 len(argumenst.split(','))) 15887 15888 dates = values.split(',')[0].split(',') 15889 fold = values.split(',')[1] 15890 15891 confiles = files_folder(fold,ncfile) 15892 Nfiles = len(confiles) 15893 15894 print ' ' + fname +': looking on:',Nfiles,'files' 15895 print confiles 15896 15897 # Opening all files and getting times 15898 ncobjs = {} 15899 for filen in confiles: 15900 print 'charging: ',filen 15901 filename = fold + '/' + filen 15902 ncf = NetCDFFile(fname, 'r') 15903 if varn == 'WRFt': 15904 fdates = ncf.variables['Times'][:] 15905 datesv = datetimeStr_conversion(fdates, 'WRFdatetime', 'YmdHMS') 15906 else: 15907 tunits = ncf.variables[varn].getncattr('units') 15908 fdates = ncf.variables[varn][:] 15909 datesv = datetimeStr_conversion(fdates, 'cfTime,' + tunits , 'YmdHMS') 15910 15911 ncobjs[fname] = datesv 15912 15913 founddates = {} 15914 for dt in dates: 15915 for fn in ncobjs.keys(): 15916 if searchInlist(ncobjs[fn], dt): 15917 founddates[dt] = fn 15918 istep = ncobjs[fn].index(dt) 15919 15920 print fname + ':',dt,fn,istep 15921 15922 return 15868 15923 15869 15924 #quit()
Note: See TracChangeset
for help on using the changeset viewer.