from __future__ import absolute_import
from casatasks.private.casa_transition import is_CASA6
if is_CASA6:
from casatools import atmosphere, table, ms, quanta, measures
from casatasks import casalog
else:
from taskinit import *
from casac import atmosphere, table, ms, quanta, measures
mytb = table( )
myms = ms( )
myqa = quanta( )
myme = measures( )
import pylab as pl
import numpy as np
from math import pi,floor
import os.path as osp
def _find(condition):
"""Returns indices where ravel(a) is true.
Private implementation of deprecated matplotlib.mlab.find
Thanks to: https://github.com/python-control/python-control/pull/262/files
"""
return np.nonzero(np.ravel(condition))[0]
def jm_clip_Yticks():
xa=pl.gca()
nlabels=0
for label in xa.yaxis.get_ticklabels():
nlabels+=1
thislabel=0
if nlabels>3:
for label in xa.yaxis.get_ticklabels():
if thislabel==0: label.set_alpha(0)
if thislabel==nlabels-1: label.set_alpha(0)
thislabel+=1
def jm_set_Ylabel_pos(pos=(0.5,0.5)):
ax=pl.gca();
ax.yaxis.set_label_position('right')
ax.yaxis.label.set_rotation(270)
ax.yaxis.label.set_position(pos)
def jm_set_Ylim_ticks(myMin=-1,myMax=1):
myYlocs=pl.linspace(round(myMin,1),round(myMax,1),5)
myLocator = pl.FixedLocator(myYlocs)
ax=pl.gca()
ax.yaxis.set_major_locator( myLocator )
pl.ylim(myMin,myMax)
jm_clip_Yticks()
def jm_set_Yvar_ticks(myScale=4):
xa=pl.gca()
xa.yaxis.set_major_locator(pl.MaxNLocator(myScale))
jm_clip_Yticks()
def Tau_K_Calc(D,T,day, weights=(.5,.5)):
P = pl.exp(1.81+(17.27*D)/(D+237.3))
h = 324.7*P/(T+273.15)
tau_w = 3.8 + 0.23*h + 0.065*h**2
if day > 199: day = day - 365.
m = day + 165.
tau_d = 22.1 - 0.178*m + 0.00044*m**2
tau_k = weights[0]*tau_w + weights[1]*tau_d
return tau_k, h