Changeset 934 for trunk/UTIL
- Timestamp:
- Apr 22, 2013, 7:20:23 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r933 r934 153 153 color=None,\ 154 154 label=None,\ 155 changetime=None,\ 155 156 title=None): 156 157 self.request = None … … 184 185 self.folder = folder 185 186 self.includedate = includedate 187 self.changetime = changetime 186 188 ## here are user-defined plot settings 187 189 ## -- if not None, valid on all plots in the pp() objects … … 243 245 self.title = other.title 244 246 self.includedate = other.includedate 247 self.changetime = other.changetime 245 248 else: 246 249 print "!! ERROR !! argument must be a pp object." ; exit() … … 541 544 ### get x,y,z,t dimensions from file 542 545 obj.getdim() 546 ### possible time axis change 547 obj.changetime = self.changetime 548 obj.performtimechange() 543 549 ### get methods 544 550 obj.method_x = mx ; obj.method_y = my … … 1069 1075 self.swap_axes = False ; self.invert_axes = False 1070 1076 self.compute = None 1077 self.changetime = None 1071 1078 1072 1079 # open a file. for now it is netcdf. TBD for other formats. … … 1181 1188 if self.dim_t > 1: 1182 1189 if self.verbose: print "**** OK. t axis %4.0f values [%5.1f,%5.1f]" % (self.dim_t,self.field_t.min(),self.field_t.max()) 1190 1191 # change time axis 1192 # ... add your options here! 1193 # -------------------------- 1194 def performtimechange(self): 1195 if self.changetime is not None \ 1196 and self.name_t != "t grid points": 1197 if self.verbose: print "**** OK. Converting time axis:",self.changetime 1198 if self.changetime == "mars_sol2ls": 1199 self.field_t = ppcompute.mars_sol2ls(self.field_t) 1200 else: 1201 print "!! WARNING !! This time change is not implemented. Nothing is done." 1183 1202 1184 1203 # get list of index to be retrieved for time axis -
trunk/UTIL/PYTHON/planetoplot_v2/ppcompute.py
r910 r934 7 7 # added librairies 8 8 import numpy as np 9 import math as m 9 10 import scipy.signal as sp_signal 10 11 ############################################### … … 173 174 y=np.convolve(w/w.sum(),s,mode='valid') 174 175 return y 176 177 ######################## 178 #### TIME CONVERTER #### 179 ######################## 180 181 # mars_sol2ls 182 # author T. Navarro 183 # ----------------- 184 # convert a given martian day number (sol) 185 # into corresponding solar longitude, Ls (in degr.), 186 # where sol=0=Ls=0 is the 187 # northern hemisphere spring equinox. 188 # ----------------- 189 def mars_sol2ls(soltabin): 190 year_day = 668.6 191 peri_day = 485.35 192 e_elips = 0.09340 193 radtodeg = 57.2957795130823 194 timeperi = 1.90258341759902 195 if type(soltabin).__name__ in ['int','float','float32','float64']: 196 soltab=[soltabin] 197 solout=np.zeros([1]) 198 else: 199 soltab=soltabin 200 solout=np.zeros([len(soltab)]) 201 i=0 202 for sol in soltab: 203 zz=(sol-peri_day)/year_day 204 zanom=2.*np.pi*(zz-np.floor(zz)) 205 xref=np.abs(zanom) 206 # The equation zx0 - e * sin (zx0) = xref, solved by Newton 207 zx0=xref+e_elips*m.sin(xref) 208 iter=0 209 while iter <= 10: 210 iter=iter+1 211 zdx=-(zx0-e_elips*m.sin(zx0)-xref)/(1.-e_elips*m.cos(zx0)) 212 if(np.abs(zdx) <= (1.e-7)): 213 continue 214 zx0=zx0+zdx 215 zx0=zx0+zdx 216 if(zanom < 0.): zx0=-zx0 217 # compute true anomaly zteta, now that eccentric anomaly zx0 is known 218 zteta=2.*m.atan(m.sqrt((1.+e_elips)/(1.-e_elips))*m.tan(zx0/2.)) 219 # compute Ls 220 ls=zteta-timeperi 221 if(ls < 0.): ls=ls+2.*np.pi 222 if(ls > 2.*np.pi): ls=ls-2.*np.pi 223 # convert Ls in deg. 224 ls=radtodeg*ls 225 solout[i]=ls 226 i=i+1 227 return solout 228
Note: See TracChangeset
for help on using the changeset viewer.