Skip to content

Commit

Permalink
Merge pull request #71 from ECCCO-mission/adds-masking
Browse files Browse the repository at this point in the history
adds masking option
  • Loading branch information
jmbhughes authored Jun 26, 2024
2 parents 17fe24d + c2453be commit 4d9cb20
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ is divided into sections:
**paths** section
------------------

There are four configurables for this section:
There are five configurables for this section:

- *overlappogram*: path to the overlappogram image to be inverted.
- *weights*: path to the accompanying weights used in the inversion. Weights should be in units of :math:`\frac{1}{\sigma}` where :math:`\sigma` is the uncertainty or standard deviation
- *weights*: path to the accompanying weights used in the inversion. Weights should be in units of :math:`\frac{1}{\sigma}` where :math:`\sigma` is the uncertainty or standard deviation. Weights are optional and the keyword can be omitted to run in weightless mode.
- *mask*: path to the accompanying mask used in the inversion. This mask is optional and the keyword can be omitted to run without a mask.
- *response*: path to the instrument response.
- *gnt*: path to the file containing atomic physics values from Chianti, the *G(n, t)* function.

Expand Down
7 changes: 4 additions & 3 deletions example_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[paths]
overlappogram = "./data/ECCCO_speedtest_runs/combined_ECCCO_trim_sw_lw_s_i_scaled.fits"
weights = "data/ECCCO_speedtest_runs/combined_ECCCO_weights_trim_sw_lw_s_i_scaled.fits"
weights = "data/ECCCO_speedtest_runs/combined_ECCCO_weights_trim_sw_lw_s_i_scaled.fits" # optional, omit keyword to skip
#mask = "no example" # mask has been commented out since we do not use it in this example
response = "data/ECCCO_speedtest_runs/D27Feb2024_eccco_response_feldman_m_el_with_tables_trim_sw_lw_s_i_scaled.fits"
gnt = "data/ECCCO_speedtest_runs/master_gnt_eccco_inphotons_cm3persperpix_with_tables.fits"

Expand All @@ -12,14 +13,14 @@ overwrite = true

[inversion]
solution_fov_width = 2
detector_row_range = [0, 50]
detector_row_range = [0, 500]
field_angle_range = [-1227, 1227]
response_dependency_name = "logt"
response_dependency_list = [5.7, 5.8, 5.9, 6.0 , 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8]
smooth_over = 'dependence'

[model]
alphas = [3E-5] #, 4E-5, 0.1] #[0.2, 0.1, 0.01, 0.005]
alphas = [3E-5, 4E-5, 0.1, 0.2, 0.1, 0.01, 0.005]
rhos = [0.1]
warm_start = false
tol = 1E-2
Expand Down
3 changes: 2 additions & 1 deletion overlappogram/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def unfold(config):
os.makedirs(config["output"]["directory"], exist_ok=True) # make sure output directory exists

overlappogram = load_overlappogram(config["paths"]["overlappogram"],
config["paths"]["weights"] if 'weights' in config['paths'] else None)
config["paths"]["weights"] if 'weights' in config['paths'] else None,
config["paths"]["mask"] if 'mask' in config['paths'] else None)
response_cube = load_response_cube(config["paths"]["response"])

inversion = Inverter(
Expand Down
10 changes: 8 additions & 2 deletions overlappogram/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'ELECDIST']


def load_overlappogram(image_path: str, weights_path: str | None) -> NDCube:
def load_overlappogram(image_path: str, weights_path: str | None = None, mask_path: str | None = None) -> NDCube:
with fits.open(image_path) as image_hdul:
image = image_hdul[0].data
header = image_hdul[0].header
Expand All @@ -32,7 +32,13 @@ def load_overlappogram(image_path: str, weights_path: str | None) -> NDCube:
weights = weights_hdul[0].data
uncertainty = StdDevUncertainty(1 / weights)

return NDCube(image, wcs=wcs, uncertainty=uncertainty, meta=dict(header))
if mask_path is None:
mask = None
else:
with fits.open(mask_path) as mask_hdul:
mask = mask_hdul[0].data

return NDCube(image, wcs=wcs, uncertainty=uncertainty, mask=mask, meta=dict(header))


def load_response_cube(path: str) -> NDCube:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = ["setuptools",

[project]
name = "overlappogram"
version = "0.0.6"
version = "0.0.7"
dependencies = ["numpy<2.0.0",
"astropy",
"scikit-learn",
Expand Down

0 comments on commit 4d9cb20

Please sign in to comment.