Skip to content

Commit 4d9cb20

Browse files
authored
Merge pull request #71 from ECCCO-mission/adds-masking
adds masking option
2 parents 17fe24d + c2453be commit 4d9cb20

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

docs/configuration.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ is divided into sections:
2020
**paths** section
2121
------------------
2222

23-
There are four configurables for this section:
23+
There are five configurables for this section:
2424

2525
- *overlappogram*: path to the overlappogram image to be inverted.
26-
- *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
26+
- *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.
27+
- *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.
2728
- *response*: path to the instrument response.
2829
- *gnt*: path to the file containing atomic physics values from Chianti, the *G(n, t)* function.
2930

example_config.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[paths]
22
overlappogram = "./data/ECCCO_speedtest_runs/combined_ECCCO_trim_sw_lw_s_i_scaled.fits"
3-
weights = "data/ECCCO_speedtest_runs/combined_ECCCO_weights_trim_sw_lw_s_i_scaled.fits"
3+
weights = "data/ECCCO_speedtest_runs/combined_ECCCO_weights_trim_sw_lw_s_i_scaled.fits" # optional, omit keyword to skip
4+
#mask = "no example" # mask has been commented out since we do not use it in this example
45
response = "data/ECCCO_speedtest_runs/D27Feb2024_eccco_response_feldman_m_el_with_tables_trim_sw_lw_s_i_scaled.fits"
56
gnt = "data/ECCCO_speedtest_runs/master_gnt_eccco_inphotons_cm3persperpix_with_tables.fits"
67

@@ -12,14 +13,14 @@ overwrite = true
1213

1314
[inversion]
1415
solution_fov_width = 2
15-
detector_row_range = [0, 50]
16+
detector_row_range = [0, 500]
1617
field_angle_range = [-1227, 1227]
1718
response_dependency_name = "logt"
1819
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]
1920
smooth_over = 'dependence'
2021

2122
[model]
22-
alphas = [3E-5] #, 4E-5, 0.1] #[0.2, 0.1, 0.01, 0.005]
23+
alphas = [3E-5, 4E-5, 0.1, 0.2, 0.1, 0.01, 0.005]
2324
rhos = [0.1]
2425
warm_start = false
2526
tol = 1E-2

overlappogram/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def unfold(config):
3232
os.makedirs(config["output"]["directory"], exist_ok=True) # make sure output directory exists
3333

3434
overlappogram = load_overlappogram(config["paths"]["overlappogram"],
35-
config["paths"]["weights"] if 'weights' in config['paths'] else None)
35+
config["paths"]["weights"] if 'weights' in config['paths'] else None,
36+
config["paths"]["mask"] if 'mask' in config['paths'] else None)
3637
response_cube = load_response_cube(config["paths"]["response"])
3738

3839
inversion = Inverter(

overlappogram/io.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'ELECDIST']
2020

2121

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

35-
return NDCube(image, wcs=wcs, uncertainty=uncertainty, meta=dict(header))
35+
if mask_path is None:
36+
mask = None
37+
else:
38+
with fits.open(mask_path) as mask_hdul:
39+
mask = mask_hdul[0].data
40+
41+
return NDCube(image, wcs=wcs, uncertainty=uncertainty, mask=mask, meta=dict(header))
3642

3743

3844
def load_response_cube(path: str) -> NDCube:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires = ["setuptools",
55

66
[project]
77
name = "overlappogram"
8-
version = "0.0.6"
8+
version = "0.0.7"
99
dependencies = ["numpy<2.0.0",
1010
"astropy",
1111
"scikit-learn",

0 commit comments

Comments
 (0)