From 8dad7e279d9fa25cdc838c8355a1b1a11ce04cb4 Mon Sep 17 00:00:00 2001 From: Andrea Zonca Date: Sun, 16 Sep 2012 18:18:13 -0700 Subject: [PATCH] support for rimo instead of instrument db --- planck/LFI.py | 12 ++++++++++-- planck/pointing.py | 11 +++++++++-- planck/ps.py | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/planck/LFI.py b/planck/LFI.py index 5618bee..f11168a 100644 --- a/planck/LFI.py +++ b/planck/LFI.py @@ -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] @@ -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 diff --git a/planck/pointing.py b/planck/pointing.py index 587c11e..0e0a415 100644 --- a/planck/pointing.py +++ b/planck/pointing.py @@ -14,6 +14,7 @@ import correction import glob import os +import exceptions class IDBSiam: def __init__(self, instrument_db, obt, Pxx=False): @@ -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 diff --git a/planck/ps.py b/planck/ps.py index 86dd3ee..353b02b 100644 --- a/planck/ps.py +++ b/planck/ps.py @@ -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')