- Timestamp:
- Jan 21, 2016, 10:34:23 AM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r673 r678 2535 2535 draw_timeSeries(filen, values, variable): 2536 2536 filen= name of the file 2537 values= [gvarname]:[timetit]:[tkind]:[timefmt]:[title]:[locleg]:[gkind]:[colorlines]:[pointtype] 2537 values= [gvarname]:[timetit]:[tkind]:[timefmt]:[title]:[locleg]:[gkind]:[colorlines]:[pointtype]:[pointfreq] 2538 2538 [gvarname]: name of the variable to appear in the graph 2539 2539 [timetit]: title of the time axis (assumed x-axis, '|' for spaces) … … 2555 2555 [pointtype]: ',' list of type of points for the lines, None for automatic, single 2556 2556 value all the same 2557 [pointfreq]: frequency of point plotting, 'all' for all time steps 2557 2558 variables= [varname],[timename] names of variable and variable with times 2558 2559 draw_timeSeries('wrfout_d01_1979-12-01_00:00:00_bottom_top_B6-E6-I1_south_north_B3-E3-I1_west_east_B26-E26-I1.nc', 'dt_con:time|($[DD]^{[HH]}$):exct,12,h:$%d^{%H}$:time|evolution|at|-1|6|3|26:1:pdf', 'LDQCON,time') … … 2567 2568 2568 2569 expectargs = ['[gvarname]', '[timetit]', '[tkind]', '[timefmt]', '[title]', \ 2569 '[locleg]', '[gkind]', '[colorlines]', '[pointtype]' ]2570 '[locleg]', '[gkind]', '[colorlines]', '[pointtype]','[pointfreq]'] 2570 2571 2571 2572 drw.check_arguments(fname,len(expectargs),values,':',expectargs) … … 2580 2581 colorlines = values.split(':')[7] 2581 2582 pointtype = values.split(':')[8] 2583 pointfreq0 = values.split(':')[9] 2582 2584 2583 2585 ncobj = NetCDFFile(filen, 'r') … … 2622 2624 pttype = pointtype.split(',') 2623 2625 2626 if pointfreq0 == 'all': 2627 pointfreq = None 2628 else: 2629 pointfreq = int(pointfreq0) 2630 2624 2631 drw.plot_TimeSeries(tseriesvals, Spot + drw.units_lunits(gunits), tunits, \ 2625 'TimeSeries', gvarname, timetit, tkind, timefmt, title, \2626 gvarname.replace('_','\_'), locleg, gkind, collines, pttype )2632 'TimeSeries', gvarname, timetit, tkind, timefmt, title, \ 2633 gvarname.replace('_','\_'), locleg, gkind, collines, pttype, pointfreq) 2627 2634 2628 2635 return -
trunk/tools/drawing_tools.py
r673 r678 2454 2454 2455 2455 def plot_TimeSeries(valtimes, vunits, tunits, hfileout, vtit, ttit, tkind, tformat, \ 2456 tit, linesn, lloc, kfig,coll,ptl ):2456 tit, linesn, lloc, kfig,coll,ptl,ptf): 2457 2457 """ Function to draw time-series 2458 2458 valtimes= list of arrays to plot [vals1[1values, 1times], [...,valsM[Mvals,Mtimes]]) … … 2480 2480 ptl= ',' list of type of points for the lines, None for automatic, single 2481 2481 value all the same 2482 ptf= frequency of point plotting, 'all' for all time steps 2482 2483 """ 2483 2484 fname = 'plot_TimeSeries' … … 2490 2491 Nlines = len(valtimes) 2491 2492 # Canging line kinds every 7 lines (end of standard colors) 2493 pointkindsauto=['.', 'x', 'o', '*', 'o', '<', '>', '5'] 2494 Npts = len(pointkindsauto) 2492 2495 linekinds = [] 2496 pointkinds = [] 2493 2497 if ptl is None: 2494 linekindsauto=['.-','x-','o-'] 2495 for ptype in range(3): 2496 for ip in range(7): 2497 linekinds.append(linekindsauto[ptype]) 2498 else: 2499 if len(ptl) > 1: 2500 linekinds = ptl 2498 if ptf is None: 2499 for ptype in range(Npts): 2500 for ip in range(7): 2501 linekinds.append(pointkindsauto[ptype] + '-') 2501 2502 else: 2502 for il in range(Nlines): 2503 linekinds.append(ptl+'-') 2503 for ptype in range(Npts): 2504 for ip in range(7): 2505 linekinds.append('-') 2506 pointkinds.append(pointkindsauto[ptype]) 2507 else: 2508 if ptf is None: 2509 if len(ptl) > 1: 2510 for pt in ptl: 2511 linekinds.append(pt + '-') 2512 else: 2513 for il in range(Nlines): 2514 linekinds.append(ptl+'-') 2515 else: 2516 if len(ptl) > 1: 2517 for pt in ptl: 2518 linekinds.append('-') 2519 pointkinds.append(pt) 2520 else: 2521 for il in range(Nlines): 2522 linekinds.append('-') 2523 pointkinds = ptl 2504 2524 2505 2525 Nvalues = [] … … 2559 2579 array[0,:] = np.where(array[0,:] < 98000., None, array[0,:]) 2560 2580 2561 if coll is None: 2562 plt.plot(array[1,:],array[0,:], linekinds[il], label= linesn[il]) 2581 if ptf is None: 2582 if coll is None: 2583 if ptf is None: 2584 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il]) 2585 else: 2586 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il]) 2587 plt.plot(array[1,::ptf],array[0,::ptf], pointkinds[il], \ 2588 label=linesn[il]) 2589 else: 2590 if ptf is None: 2591 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il], \ 2592 color=coll[il]) 2593 else: 2594 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il], \ 2595 color=coll[il]) 2596 plt.plot(array[1,::ptf],array[0,::ptf], pointkinds[il], \ 2597 label=linesn[il], color=coll[il]) 2563 2598 else: 2564 plt.plot(array[1,:],array[0,:], linekinds[il], label= linesn[il], \ 2565 color=coll[il]) 2599 if coll is None: 2600 if ptf is None: 2601 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il]) 2602 else: 2603 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il]) 2604 plt.plot(array[1,::ptf],array[0,::ptf], pointkinds[il], \ 2605 label=linesn[il]) 2606 else: 2607 if ptf is None: 2608 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il], \ 2609 color=coll[il]) 2610 else: 2611 plt.plot(array[1,:],array[0,:], linekinds[il], label=linesn[il], \ 2612 color=coll[il]) 2613 plt.plot(array[1,::ptf],array[0,::ptf], pointkinds[il], \ 2614 label=linesn[il], color=coll[il]) 2566 2615 2567 2616 timevals = np.arange(xmin,xmax)*1.
Note: See TracChangeset
for help on using the changeset viewer.