- Timestamp:
- Jul 17, 2018, 11:45:19 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1937 r1945 9078 9078 quit(-1) 9079 9079 9080 if not os.path.isfile(ncfile): 9081 print errormsg 9082 print ' ' + fname + ": file '" + ncfile + "' does not exist !!" 9083 quit(-1) 9084 9080 9085 onc = NetCDFFile(ncfile, 'r') 9086 print ' ' + fname + ": getting from file '" + ncfile + "' variables:" , \ 9087 varns, 'with slice:', dimvals 9081 9088 for varn in varns: 9082 9089 if not onc.variables.has_key(varn): … … 9089 9096 ov = onc.variables[varns[0]] 9090 9097 opres = onc.variables[varns[1]] 9098 otime = onc.variables['time'] 9091 9099 9092 9100 # Getting values 9093 9101 vals, valdims = drw.slice_variable(ov, dimvals.replace(',','|')) 9094 9102 pvals, presdims = drw.slice_variable(opres, dimvals.replace(',','|')) 9103 tvals, tdims = drw.slice_variable(otime, dimvals.replace(',','|')) 9095 9104 9096 9105 # Expected masked values -
trunk/tools/drawing_tools.py
r1937 r1945 11406 11406 11407 11407 def SaturationPressure(temp): 11408 """ Provides de saturation pressure at a given temperature following The August-Roche-Magnus equation 11408 """ Provides de saturation pressure [hPa] at a given temperature following The 11409 August-Roche-Magnus equation 11409 11410 temp: temperature [K] 11411 >>> SaturationPressure(293.15) 11412 23.334406231 11410 11413 """ 11411 11414 fname = 'SaturationPressure' … … 11416 11419 11417 11420 tempC = temp - 273.15 11418 satpres = 100.*ARM1*(ARM2*tempC)/(tempC+ARM3)11421 satpres = ARM1*exp(ARM2*tempC/(tempC+ARM3)) 11419 11422 11420 11423 return satpres … … 11423 11426 11424 11427 def SatMixingRatio(ta,pres): 11425 """ Provides de saturation mixing ratio 11428 """ Provides de saturation mixing ratio [kgkg-1] 11426 11429 ta: temperature [K] 11427 11430 pres: pressure [Pa] 11431 >>> SatMixingRatio(293.,101300.) 11432 0.014531424608 11428 11433 """ 11429 11434 fname = 'SatMixingRatio' 11430 11435 11431 11436 es = SaturationPressure(ta) 11432 rs = (0.6222*es)/( pres-es)11437 rs = (0.6222*es)/(0.01*pres-es) 11433 11438 11434 11439 return rs … … 11463 11468 for iz in range(dz): 11464 11469 ethetapotv[iz,0] = psfc-dp*iz 11465 thetapotv = (tsfc+273.15)*((psfc-dp*iz)/p0)**(R/Cp) 11466 # print iz,psfc-dp*iz,thetapotv,SatMixingRatio(tsfc+273.15,psfc),np.exp(L*1000.*SatMixingRatio(tsfc+273.15,psfc)/Cp*(tsfc+273.15)) 11467 ethetapotv[iz,1] = thetapotv*np.exp(L*1000.*SatMixingRatio(tsfc+273.15,psfc)/(Cp*(tsfc+273.15))) - 273.15 11468 11469 # quit() 11470 thetapotv = (tsfc+273.15)*((psfc-dp*iz)/p0)**(R/Cp) 11471 ws = SatMixingRatio(tsfc+273.15,psfc) 11472 ethetapotv[iz,1] = thetapotv*np.exp(L*1000.*ws/(Cp*(tsfc+273.15))) -273.15 11473 print iz,psfc-dp*iz,thetapotv-273.15,ethetapotv[iz,1] 11474 11475 #quit() 11470 11476 return ethetapotv 11471 11477 … … 11533 11539 xmax = taxtrm[1] 11534 11540 xmin = taxtrm[0] 11535 print 'len:', np.arange(xmin,xmax,10.)11536 11541 if len(np.arange(xmin,xmax,10.)) < 10: xfrqtk = 10. 11537 11542 else: xfrqtk = 20. … … 11620 11625 xmax = taxtrm[1] 11621 11626 xmin = taxtrm[0] 11622 print 'len:', np.arange(xmin,xmax,10.)11623 11627 if len(np.arange(xmin,xmax,10.)) < 10: xfrqtk = 10. 11624 11628 else: xfrqtk = 20. … … 11639 11643 l = ax.axvline(0, color='C0') 11640 11644 11641 Nlines = len(kindgv['labels']) 11645 Nlines = len(tvals) 11646 NLlines = len(kindgv['labels']) 11647 if Nlines != NLlines: 11648 print errormsg 11649 print ' ' + fname + ': number of lines:', Nlines, \ 11650 ' and number of labels:', NLlines, 'do not coincide !!' 11651 print ' provided labels:', kindgv['labels'] 11652 quit(-1) 11653 11654 print ' ' + fname + ': plotting ', Nlines, 'lines ...' 11642 11655 11643 11656 for iline in range(Nlines): … … 11694 11707 plt.legend(loc=legv[0], prop={'size':legv[1]}) 11695 11708 11709 ax.set_xlabel('t ($^{\circ}$C)') 11710 ax.set_ylabel('pres (hPa)') 11711 11696 11712 ax.set_title(gen.latex_text(figtitle)) 11697 11713
Note: See TracChangeset
for help on using the changeset viewer.