Skip to content

Commit

Permalink
support for rimo instead of instrument db
Browse files Browse the repository at this point in the history
  • Loading branch information
zonca committed Sep 17, 2012
1 parent 68eca93 commit 8dad7e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions planck/LFI.py
Expand Up @@ -49,7 +49,10 @@ def wn(self):
return self.get_instrument_db_field('net_KCMB')

def get_instrument_db_field(self, field):
return self.inst.instrument_db(self)[field][0]
try:
return self.inst.instrument_db(self)[field][0]
except exceptions.ValueError:
return self.inst.instrument_db(self)[field.upper()][0]

def __getitem__(self, n):
return self.d[n]
Expand Down Expand Up @@ -98,9 +101,14 @@ def RCA_from_tag(tag):
def instrument_db(self,ch):
if not hasattr(self,'_instrument_db') or self._instrument_db is None:
import pyfits
if isinstance(self.instrument_db_file, list):
self.instrument_db_file = self.instrument_db_file[0]
self._instrument_db = np.array(pyfits.open(self.instrument_db_file,ignore_missing_end=True)[1].data)
l.warning('Loading instrumentdb %s' % self.instrument_db_file)
det_index, = np.where([rad.strip().endswith(ch.tag) for rad in self._instrument_db['Radiometer']])
try:
det_index, = np.where([rad.strip().endswith(ch.tag) for rad in self._instrument_db['Radiometer']])
except exceptions.ValueError:
det_index, = np.where([rad.strip().endswith(ch.tag) for rad in self._instrument_db['DETECTOR']])
return self._instrument_db[det_index]

@property
Expand Down
11 changes: 9 additions & 2 deletions planck/pointing.py
Expand Up @@ -14,6 +14,7 @@
import correction
import glob
import os
import exceptions

class IDBSiam:
def __init__(self, instrument_db, obt, Pxx=False):
Expand All @@ -24,10 +25,16 @@ def __init__(self, instrument_db, obt, Pxx=False):
l.warning("Using IDB: " + os.path.basename(instrument_db))
self.uv_angles = {}
for row in np.array(pyfits.open(instrument_db)[1].data):
radtag = row["Radiometer"].strip()
try:
radtag = row["Radiometer"].strip()
except exceptions.IndexError:
radtag = row["DETECTOR"].strip()
self.uv_angles[radtag] = {}
for fi in ["theta_uv","phi_uv","psi_uv","psi_pol"]:
self.uv_angles[radtag][fi]=np.radians(row[fi])
try:
self.uv_angles[radtag][fi]=np.radians(row[fi])
except exceptions.IndexError:
self.uv_angles[radtag][fi]=np.radians(row[fi.upper()])
if Pxx:
self.uv_angles[radtag]["psi_uv"]=0
self.uv_angles[radtag]["psi_pol"]=0
Expand Down
1 change: 1 addition & 0 deletions planck/ps.py
Expand Up @@ -38,6 +38,7 @@ def smooth(m, arcmin, lmax = None):
config['infile'] = 'tempmap.fits'
config['outfile'] = 'tempmap_smoothed.fits'
config['fwhm_arcmin'] = arcmin
config['iter_order'] = 3
config.write()
if os.path.exists('tempmap_smoothed.fits'):
os.remove('tempmap_smoothed.fits')
Expand Down

0 comments on commit 8dad7e2

Please sign in to comment.