Return to sosh.py CVS log Up to [Development] / JSOC / proj / globalhs / sosh

### Diff for /JSOC/proj/globalhs/sosh/sosh.py between version 1.2 and 1.3

version 1.2, 2019/02/22 22:26:26 version 1.3, 2019/03/04 17:33:22
 Line 245  def setplm(l, m, x, plm, dplm):
 Line 245  def setplm(l, m, x, plm, dplm):
return (plm[...,l-m],dplm[...,l-m])   return (plm[...,l-m],dplm[...,l-m])

lsave=0  lsave=[0]
msave=0  msave=[0]
nsave=1  nsave=[1]

def querylmn():  def querylmn(index):

global lsave, msave, nsave   global lsave, msave, nsave
lstr=catchc("Enter spherical harmonic degree (l): ",lsave)    if (index < 0):
if (index < -len(lsave)):
i=-len(lsave)
else:
i=index
else:
i=-1
lstr=catchc("Enter spherical harmonic degree (l): ",lsave[i])
if lstr == 'q':   if lstr == 'q':
return (-1,-1,-1)     return (-1,-1,-1)
else:   else:
 Line 261  def querylmn():
 Line 268  def querylmn():
lval=int(lstr)         lval=int(lstr)
if lval < 0:         if lval < 0:
print("Degree must be greater than or equal to zero. Try again.")           print("Degree must be greater than or equal to zero. Try again.")
lstr=catchc("Enter spherical harmonic degree (l): ",lsave)            lstr=catchc("Enter spherical harmonic degree (l): ",lsave[i])
if lstr == 'q':           if lstr == 'q':
return (-1,-1,-1)             return (-1,-1,-1)
continue           continue
break         break
except:       except:
print("Invalid number, try again.")         print("Invalid number, try again.")
lstr=catchc("Enter spherical harmonic degree (l): ", lsave)          lstr=catchc("Enter spherical harmonic degree (l): ", lsave[i])
if lstr == 'q':         if lstr == 'q':
return (-1,-1,-1)           return (-1,-1,-1)

mstr=catchc("Enter azimuthal order (m): ",msave)    mstr=catchc("Enter azimuthal order (m): ",msave[i])
if mstr == 'q':   if mstr == 'q':
return (-1,-1,-1)     return (-1,-1,-1)
else:   else:
 Line 281  def querylmn():
 Line 288  def querylmn():
mval=int(mstr)         mval=int(mstr)
if np.abs(mval) > lval:         if np.abs(mval) > lval:
print("Azimuthal order must be in the range -l <= m <= l. Try again.")           print("Azimuthal order must be in the range -l <= m <= l. Try again.")
mstr=catchc("Enter azimuthal order (m): ",msave)            mstr=catchc("Enter azimuthal order (m): ",msave[i])
if mstr == 'q':           if mstr == 'q':
return (-1,-1,-1)             return (-1,-1,-1)
continue           continue
break         break
except:       except:
print("Invalid number, try again.")         print("Invalid number, try again.")
mstr=catchc("Enter azimuthal order (m): ",msave)          mstr=catchc("Enter azimuthal order (m): ",msave[i])
if mstr == 'q':         if mstr == 'q':
return (-1,-1,-1)           return (-1,-1,-1)

if nstr == 'q':   if nstr == 'q':
return (-1,-1,-1)     return (-1,-1,-1)
else:   else:
 Line 301  def querylmn():
 Line 308  def querylmn():
nval=int(nstr)         nval=int(nstr)
if nval < 0:         if nval < 0:
print("Radial order must be greater than or equal to zero. Try again.")           print("Radial order must be greater than or equal to zero. Try again.")
if nstr == 'q':           if nstr == 'q':
return (-1,-1,-1)             return (-1,-1,-1)
continue           continue
break         break
except:       except:
print("Invalid number, try again.")         print("Invalid number, try again.")
if nstr == 'q':         if nstr == 'q':
return (-1,-1,-1)           return (-1,-1,-1)

lsave=lval    lsave.append(lval)
msave=mval    msave.append(mval)
nsave=nval    nsave.append(nval)
return (lval,mval,nval)   return (lval,mval,nval)

 Line 394  def catchc(prompt, saveval):
 Line 401  def catchc(prompt, saveval):
return c       return c
valstr=input(prompt)     valstr=input(prompt)
if (valstr == ''):   if (valstr == ''):
print("Using saved value %i." % saveval)      print("Using saved value %s." % str(saveval))
valstr=str(saveval)     valstr=str(saveval)
return valstr   return valstr

 Line 498  def drawfigure(var, fsize=5):
 Line 505  def drawfigure(var, fsize=5):

def savefigure(ianimate=1, label=''): def savefigure(ianimate=1, label=''):

l=lsave    l=lsave[-1]
m=msave    m=msave[-1]
n=nsave    n=nsave[-1]
if (ianimate == 0):   if (ianimate == 0):
savestr='png_out/'+plotvar+label+'.l%im%in%i.png' % (l,m,n)     savestr='png_out/'+plotvar+label+'.l%im%in%i.png' % (l,m,n)
plt.savefig(savestr, dpi=dpi)     plt.savefig(savestr, dpi=dpi)

Legend:
 Removed from v.1.2 changed lines Added in v.1.3