Changeset 1763 in lmdz_wrf
- Timestamp:
- Jan 24, 2018, 4:06:22 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1589 r1763 2339 2339 """ Function to draw different lines at the same time from different files with times 2340 2340 draw_lines_time(ncfilens, values, varname): 2341 ncfilens= [filen] ',' separated list of netCDF files 2341 ncfilens= [filen]%[dimval] ',' separated list of netCDF files and the 'slice' 2342 along the dimensions of the file 2343 [dimval]: ';' list of [dimn]|[dimval] to get the values for [varn] 2344 [dimn]: name of the dimension 2345 [dimval]: value of the dimension variable a given value is required: 2346 * [integer]: which value of the dimension 2347 * -1: all along the dimension 2348 * -9: last value of the dimension 2349 * [beg]@[end]@[inc] slice from [beg] to [end] every [inc] 2350 * NOTE, no dim name all the dimension size 2342 2351 values= [dimvname];[valuesaxis];[dimtit];[dimxyfmt];[leglabels];[vtit];[title];[rangevals];[timevals]; 2343 2352 [legvals];[graphk];[collines];[points];[linewidths];[pointsizes];[pointfreq];[period];[close] 2344 [dimvname]: ',' list of names of the variables with he values of the common dimension('WRFtime' for WRF Times variable)2353 [dimvname]: ',' list of names of the variables with the values of the common dimension for all lines ('WRFtime' for WRF Times variable) 2345 2354 [valuesaxis]: which axis will be used for the values ('x', or 'y') 2346 2355 [dimtit]: title for the common dimension ('|' for spaces) … … 2366 2375 [timen]; name of the time variable 2367 2376 [units]; units string according to CF conventions ([tunits] since 2368 [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces) 2377 [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces) this is used to 2378 re-compute the time values to be the same reference for all the lines 2369 2379 [kind]; kind of output 2370 2380 'Nval': according to a given number of values as 'Nval',[Nval] … … 2380 2390 9: 'upper center', 10: 'center' 2381 2391 [fontsize]: font size for the legend (auto for 12) 2382 [graphk]: kind of the graphic 2383 [lines]: ',' list of type of lines, None for automatic, single value all the same 2384 [collines]: ',' list of colors for the lines, None for automatic, single 2385 value all the same 2386 [points]: '@' list of type of points for the lines, None for automatic, single 2387 value all the same 2392 [graphk]: kind of the output of the graphic ('png', 'pdf', 'eps', ...) 2393 [lines]: ',' list of type of lines (matplotlib syntax), 'None' for automatic, 2394 providing a single value will be used the same for all the lines 2395 [collines]: ',' list of colors for the lines (matplotlib syntax), 'None' for 2396 automatic, single value all the same 2397 [points]: '@' list of type of points (matplotlib syntax ',' no points) for 2398 the lines, 'None' for automatic, single value all the same 2388 2399 [linewidths]: ',' list of widths for the lines, None for automatic, single 2389 2400 value all the same 2390 2401 [pointsizes]: ',' list of widths for the lines, None for automatic, single 2391 2402 value all the same 2392 [pointfreq]: frequency of point plotting, 'all' for all time steps 2393 [period]: which period to plot 2394 '-1': all period 2395 [beg],[end]: beginning and end of the period in reference time-units of first file 2403 [pointfreq]: frequency of point plotting (every given number of values), 2404 'all' to plot all values using all time steps 2405 [period]: which period of the data to plot: 2406 '-1': all period of data 2407 [beg],[end]: beginning and end of the period in reference time-units of 2408 first file 2396 2409 [close]: Whether figure should be finished or not 2397 varnames= ',' list of variable names to plot (assuming only 1 variable per file) 2410 varnames= ',' list of variable names to plot (assuming only 1 variable per file 2411 consecutively) 2398 2412 values= 'time;y;time ([DD]${[HH]}$);32x32;$wss^{*}$;wss Taylor's turbulence term;time|hours!since!1949-12-01_00:00:00;exct,12,h|%d$^{%H}$;2;pdf' 2399 2413 """ … … 2411 2425 drw.check_arguments(fname,values,expectargs,';') 2412 2426 2413 ncfile s = ncfilens.split(',')2427 ncfiledims = ncfilens.split(',') 2414 2428 dimvname0 = values.split(';')[0] 2415 2429 valuesaxis = values.split(';')[1] … … 2531 2545 maxtval = -1.e20 2532 2546 2533 for ifile in ncfiles: 2534 filen = ifile.split('@')[0] 2535 2536 print ' filen:',filen 2547 for ifile in ncfiledims: 2548 2549 filen = ifile.split('%')[0] 2550 dims = ifile.split('%')[1] 2551 2552 print ' filen:', filen, 'section:', dims 2537 2553 2538 2554 if not os.path.isfile(filen): … … 2589 2605 if objfile.variables.has_key(var): 2590 2606 foundvar = True 2591 vvobj = objfile.variables[var] 2607 vvobj0 = objfile.variables[var] 2608 2609 # Slicing variables 2610 dictslice = {} 2611 for dnv in dimvalues.split(';'): 2612 dimn = dnv.split('|')[0] 2613 dimv = dnv.split('|')[1] 2614 if dimv.find(',') != -1: 2615 dictslice[dimn] = list(np.array(dimv.split('@'), dtype=int)) 2616 else: 2617 dictslice[dimn] = int(dimv) 2618 2619 slicev, ddv = ncvar.SliceVarDict(vvobj0, dictslice) 2620 vvobj = timeobj[tuple(slicet)] 2621 2592 2622 if len(vvobj.shape) != 1: 2593 2623 print errormsg … … 2671 2701 2672 2702 if ifn == 0: 2673 varunits = drw.units_lunits(vvobj.units) 2703 varunits = drw.units_lunits(vvobj0.units) 2704 else: 2705 if varunits != drw.units_lunits(vvobj0.units): 2706 print errormsg 2707 print ' ' + fname + ': wrong units:', vvobj0.units, " of " + \ 2708 "variable '" + var + "' with respect first variable '", varunits, \ 2709 "' !!" 2710 quit(-1) 2674 2711 2675 2712 objfile.close()
Note: See TracChangeset
for help on using the changeset viewer.