Changeset 782
- Timestamp:
- Sep 13, 2012, 12:29:15 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r781 r782 30 30 31 31 ## Author: AS + AC 32 def localtime(time,lon,nc): # lon is the mean longitude of the plot, not of the domain. central lon of domain is taken from cen_lon 33 import numpy as np 34 dt_hour=1. 35 start=0. 32 def localtime(time,lon,namefile): # lon is the mean longitude of the plot, not of the domain. central lon of domain is taken from cen_lon 33 import numpy as np 34 from netCDF4 import Dataset 35 ## THIS IS FOR MESOSCALE 36 nc = Dataset(namefile) 37 ## get start date and intervals 38 dt_hour=1. ; start=0. 39 if hasattr(nc,'TITLE'): 40 title=getattr(nc, 'TITLE') 41 if hasattr(nc,'DT') and hasattr(nc,'START_DATE') and 'MRAMS' in title: 42 ## we must adapt what is done in getlschar to MRAMS (outputs from ic.py) 43 dt_hour=getattr(nc, 'DT')/60. 44 start_date=getattr(nc, 'START_DATE') 45 start_hour=np.float(start_date[11:13]) 46 start_minute=np.float(start_date[14:16])/60. 47 start=start_hour+start_minute # start is the local time of simu at longitude 0 48 #LMD MMM is 1 output/hour (and not 1 output/timestep) 49 #MRAMS is 1 output/timestep, unless stride is added in ic.py 50 elif 'WRF' in title: 51 [dummy,start,dt_hour] = getlschar ( namefile ) # get start hour and interval hour 52 ## get longitude 36 53 if lon is not None: 37 54 if lon[0,1]!=lon[0,0]: mean_lon_plot = 0.5*(lon[0,1]-lon[0,0]) … … 39 56 elif hasattr(nc, 'CEN_LON'): mean_lon_plot=getattr(nc, 'CEN_LON') 40 57 else: mean_lon_plot=0. 41 if hasattr(nc,'TITLE'): 42 title=getattr(nc, 'TITLE') 43 if hasattr(nc,'DT') and 'MRAMS' in title: dt_hour=getattr(nc, 'DT')/60. #LMD MMM is 1 output/hour (and not 1 output/timestep) 44 # MRAMS is 1 output/timestep, unless stride is added in ic.py 45 if hasattr(nc,'START_DATE'): 46 start_date=getattr(nc, 'START_DATE') 47 start_hour=np.float(start_date[11:13]) 48 start_minute=np.float(start_date[14:16])/60. 49 start=start_hour+start_minute # start is the local time of simu at longitude 0 50 ltst = start + time*dt_hour + mean_lon_plot / 15. 51 else: ltst = time*dt_hour + mean_lon_plot / 15. 52 else: ltst = time*dt_hour + mean_lon_plot / 15. 58 ## calculate local time 59 ltst = start + time*dt_hour + mean_lon_plot / 15. 53 60 ltst = int (ltst * 10) / 10. 54 61 ltst = ltst % 24 -
trunk/UTIL/PYTHON/planetoplot.py
r781 r782 299 299 if axtime in ["lt"]: 300 300 ftime = np.zeros(len(time)) 301 for i in range(len(time)): 302 ftime[i] = localtime ( time[i], slon , nc ) 303 time=ftime 304 time=check_localtime(time) 301 for i in range(len(time)): ftime[i] = localtime ( time[i], slon , namefile ) 302 time=ftime ; time=check_localtime(time) 305 303 print "LOCAL TIMES.... ", time 306 304 ### we define the vertical axis (or lack thereof) and cover possibilities for it to be altitude, pressure, geopotential. quite SPECIFIC. … … 463 461 else: indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 464 462 ltst = None 465 if typefile in ['meso'] and indextime is not None and len(indextime) < 2: ltst = localtime ( indextime, slon , nc)463 if typefile in ['meso'] and indextime is not None and len(indextime) < 2: ltst = localtime ( indextime, slon , all_namefile[index_f]) 466 464 print "********** INDEX LON:",indexlon," LAT:",indexlat," VERT:",indexvert," TIME:",indextime 467 465 ##var = nc.variables["phisinit"][:,:]
Note: See TracChangeset
for help on using the changeset viewer.