Example #1
0
   ralabel = map(lambda a: a/3600.,tmplabel) # convert to hours
   stepra  = map(lambda a: a/3600.,tmpstep)  # convert to hours

   tmp = abs(maxra - minra)
   guess = tmp/6. # aim for about 6 labels
   diff  = [abs(guess-a) for a in ralabel]
   idx   = diff.index(min(diff))
   
   return stepra[idx],ralabel[idx]
 
if __name__ == "__main__":
   arg = ReadCmd(spec)
   image      = arg.getstr('in',exist=True)
   rangex     = arg.getlistfloat('xrange',length=2)
   rangey     = arg.getlistfloat('yrange',length=2)
   tmplength  = arg.getfloat('length')
   tmpra      = arg.getlistfloat('ra',length=2)
   tmpdec     = arg.getlistfloat('dec',length=2)
   outfile    = arg.getstr('out',exist=False)

   import worldpos
   wcs = worldpos.wcs(image)
   if wcs.header['rot'] != 0:
      error('WIP cannot handle rotations!')
      
   if len(rangex) == 0:
      xmin = 0.5
      xmax = naxis1 + 0.5
   else:
      xmin = rangex[0] - 0.5
      xmax = rangex[1] + 0.5
Example #2
0
   else:
      Av = None
      dAv = None
   return Av,dAv
   
def rjce(intrinsic, magj, sigmaj, magh, sigmah, magks, sigmaks):
   """Compute extinction using RJCE (Majewski TODO)"""
   
   return None,None

if __name__ == "__main__":
   arg = ReadCmd(spec)
   infile  = arg.getstr("in",exist=True)
   outfile = arg.getstr("out",exist=False)
   intrinsic = {}
   intrinsic['k1']  = 1./arg.getfloat("avaj")
   intrinsic['k2']  = 1./arg.getfloat("avah")
   intrinsic['jh']  = arg.getlistfloat("jh")
   intrinsic['hk']  = arg.getlistfloat("hk")
   intrinsic['cov'] = arg.getfloat("cov")
   intrinsic['method'] =  arg.getstr("method",option=['jh','hk','nicer','rjce'])

   from numpy import loadtxt,savetxt,sqrt

   data = loadtxt(infile,dtype=str)
   d    = data[:,2:8].astype(float)
   if intrinsic['method'] == 'jh' or intrinsic['method'] == 'hk':
      Av,dAv = nice(intrinsic, d[:,0],d[:,1],d[:,2],d[:,3],d[:,4],d[:,5])
   elif intrinsic['method'] == 'nicer':
      Av,dAv = nicer(intrinsic,d[:,0],d[:,1],d[:,2],d[:,3],d[:,4],d[:,5])
   elif intrinsic['method'] == 'rjce':
Example #3
0
          in    = ???  # Input data file
          xcol  = 1    # x column (1-based)
          ycol  = 2    # y column (set to None to skip)
          dxcol = None # x errors column
          dycol = None # y errors column
          xmin  = None # Min value for bins (defaults to data min)
          xmax  = None # Max value for bins (defaults to data max)
          nbin  = 10   # Number of bins"""
   
arg = ReadCmd(spec)
infile = arg.getstr("in",exist=True)
xcol   = arg.getint("xcol",min=1)
ycol   = arg.getint("ycol",min=1)
dxcol  = arg.getint("dxcol",min=1)
dycol  = arg.getint("dycol",min=1)
xmin   = arg.getfloat("xmin")
xmax   = arg.getfloat("xmax")
nbin   = arg.getint("nbin",min=1)

if xcol is None:
   arg.error("You must specify a column number for x!")
   
cols = []
for i in [xcol,ycol,dxcol,dycol]:
   if i is not None:
      cols.append(i-1)

errxFlag = True # set to false if no x errors
erryFlag = True # set to false if no y errors

# load data
Example #4
0
    stepra = map(lambda a: a / 3600., tmpstep)  # convert to hours

    tmp = abs(maxra - minra)
    guess = tmp / 6.  # aim for about 6 labels
    diff = [abs(guess - a) for a in ralabel]
    idx = diff.index(min(diff))

    return stepra[idx], ralabel[idx]


if __name__ == "__main__":
    arg = ReadCmd(spec)
    image = arg.getstr('in', exist=True)
    rangex = arg.getlistfloat('xrange', length=2)
    rangey = arg.getlistfloat('yrange', length=2)
    tmplength = arg.getfloat('length')
    tmpra = arg.getlistfloat('ra', length=2)
    tmpdec = arg.getlistfloat('dec', length=2)
    outfile = arg.getstr('out', exist=False)

    import worldpos
    wcs = worldpos.wcs(image)
    if wcs.header['rot'] != 0:
        error('WIP cannot handle rotations!')

    if len(rangex) == 0:
        xmin = 0.5
        xmax = naxis1 + 0.5
    else:
        xmin = rangex[0] - 0.5
        xmax = rangex[1] + 0.5
Example #5
0
spec = """# Make a ds9 region file from vectors
          in    = ???     # Input file
          cols  = 1,2,3,5 # Columns for x,y,polarization,angle
          out   = ???     # Output region file
          scale = 5       # length of 1% polarization (in pixels or arcsec)
          color = green   # Color for region file
          width = 1       # Line width
          coord = fk5     # coordinates of vectors [fk5,physical]
          mag   = p       # Make vector lengths (p)roportional or (u)niform?"""

arg = ReadCmd(spec)
infile  = arg.getstr('in',exist=True)
cols    = arg.getlistint('cols',length=4,min=1)
outfile = arg.getstr('out',exist=False)
scale   = arg.getfloat('scale')
color   = arg.getstr('color')
width   = arg.getint('width')
coord   = arg.getstr('coord',option=['fk5','physical'])
mag     = arg.getstr('mag',option=['p','u'])

from numpy import loadtxt,pi,sin,cos

cols = [a - 1 for a in cols] # make zero-based
data = loadtxt(infile,usecols=cols)

if coord == 'fk5':
   arg.warning("fk5 doesn't work correctly yet!")
   scale = scale/3600.
if mag == 'p':
   data[:,2] = scale*data[:,2]
Example #6
0
      f = _func(t,flux1,flux2,wave1,wave2,beta)
      if isfinite(f):
         sign = f/abs(f)
         start = t
         break
   for t in range(start,10000):
      f = _func(t,flux1,flux2,wave1,wave2,beta)
      s = f/abs(f)
      if sign*s == -1:
         return t
   nlclib.error('Could not estimate initial temperature for wavelengths %f,%f!' %(wave1,wave2))

if __name__ == "__main__":
   arg = ReadCmd(spec,__doc__)
   infile      = arg.getstr('in',exist=True)
   dist        = arg.getfloat('dist')
   beta        = arg.getfloat('beta')
   sumMethod   = arg.getstr('sum',option=['midpoint','simpson','trapezoid'])
      
   from numpy import loadtxt,where,exp,zeros,pi,log,seterr,arange,linspace,isnan,isfinite

   seterr(over='ignore')
   # some constants
   sun_lum  = 3.826e33      # solar luminosity in ergs/s
   parsec   = 3.08567802e18 # 1 parsec in cm
   planck   = 6.62618e-27   # Planck's constant in erg s
   light    = 2.99792458e10 # speed of light in cm/s
   boltz    = 1.38066e-16   # Boltzmann's constant in K^-1
   hck      = planck*light/boltz

   data = loadtxt(infile)