Skip to content

Commit

Permalink
Make the mask filename part of the instrument class
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Jan 26, 2021
1 parent 8505749 commit d544230
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
8 changes: 8 additions & 0 deletions pyreduce/instruments/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,14 @@ def get_supported_modes(self):
info = self.load_info()
return info["modes"]

def get_mask_filename(self, mode, **kwargs):
i = self.name.lower()
m = mode.lower()
fname = f"mask_{i}_{m}.fits.gz"
cwd = os.path.dirname(__file__)
fname = os.path.join(cwd, "..", "masks", fname)
return fname


class InstrumentWithModes(Instrument):
def __init__(self):
Expand Down
16 changes: 1 addition & 15 deletions pyreduce/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,6 @@ class Mask(Step):

def __init__(self, *args, **config):
super().__init__(*args, **config)
self._mask_dir = config["directory"]

@property
def mask_dir(self):
"""str: Directory containing the mask data file"""
this = dirname(__file__)
return self._mask_dir.format(reduce=this)

@property
def mask_file(self):
"""str: Name of the mask data file"""
i = self.instrument.name.lower()
m = self.mode.lower()
return f"mask_{i}_{m}.fits.gz"

def run(self):
"""Load the mask file from disk
Expand All @@ -315,7 +301,7 @@ def load(self):
mask : array of shape (nrow, ncol)
Bad pixel mask for this setting
"""
mask_file = join(self.mask_dir, self.mask_file)
mask_file = self.instrument.get_mask_filename(self.mode)
try:
mask, _ = self.instrument.load_fits(mask_file, self.mode, extension=0)
mask = ~mask.data.astype(bool) # REDUCE mask are inverse to numpy masks
Expand Down
4 changes: 1 addition & 3 deletions pyreduce/settings/settings_pyreduce.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"output_dir": "reduced"
},
"instrument": {},
"mask": {
"directory": "{reduce}/masks"
},
"mask": {},
"bias": {
"plot": true,
"plot_title": "Bias"
Expand Down
11 changes: 1 addition & 10 deletions pyreduce/settings/settings_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@
"type": "object"
},
"mask": {
"type": "object",
"properties": {
"directory": {
"description": "Directory containing the instrument specific mask files. May contain {file} tag, referencing the reduce script location",
"type": "string"
}
},
"required": [
"directory"
]
"type": "object"
},
"bias": {
"$ref": "#/definitions/step"
Expand Down

0 comments on commit d544230

Please sign in to comment.