Skip to content

Commit

Permalink
Add option to skip ifg corruption filter
Browse files Browse the repository at this point in the history
  • Loading branch information
dostuffthatmatters committed Jan 31, 2024
1 parent 39e8093 commit d659576
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 24 deletions.
3 changes: 2 additions & 1 deletion config/config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"store_binary_spectra": true,
"dc_min_threshold": 0.05,
"dc_var_threshold": 0.1,
"use_local_pressure_in_pcxs": true
"use_local_pressure_in_pcxs": true,
"use_ifg_corruption_filter": false
}
},
{
Expand Down
9 changes: 8 additions & 1 deletion docs/components/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ const CONFIG_SCHEMA: any = {
"description": "Whether to use the local pressure in the pcxs files. If not used, it will tell PCXS to use the pressure from the atmospheric profiles (set the input value in the `.inp` file to `9999.9`). If used, the pipeline computes the solar noon time using `skyfield` and averages the local pressure over the time period noon-2h to noon+2h.",
"title": "Use Local Pressure In Pcxs",
"type": "boolean"
},
"use_ifg_corruption_filter": {
"default": true,
"description": "Whether to use the ifg corruption filter. This filter is a program based on `preprocess4` and is part of the `tum-esm-utils` library: https://tum-esm-utils.netlify.app/api-reference#tum_esm_utilsinterferograms. If activated, we will only pass the interferograms to the retrieval algorithm that pass the filter - i.e. that won't cause it to crash.",
"title": "Use Ifg Corruption Filter",
"type": "boolean"
}
},
"title": "RetrievalJobSettingsConfig",
Expand All @@ -328,7 +334,8 @@ const CONFIG_SCHEMA: any = {
"store_binary_spectra": false,
"dc_min_threshold": 0.05,
"dc_var_threshold": 0.1,
"use_local_pressure_in_pcxs": false
"use_local_pressure_in_pcxs": false,
"use_ifg_corruption_filter": true
},
"description": "Advanced settings that only apply to this retrieval job"
}
Expand Down
6 changes: 4 additions & 2 deletions docs/pages/api-reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ import {
"store_binary_spectra": true,
"dc_min_threshold": 0.05,
"dc_var_threshold": 0.1,
"use_local_pressure_in_pcxs": true
"use_local_pressure_in_pcxs": true,
"use_ifg_corruption_filter": false
}
},
{
Expand All @@ -87,7 +88,8 @@ import {
"store_binary_spectra": false,
"dc_min_threshold": 0.05,
"dc_var_threshold": 0.1,
"use_local_pressure_in_pcxs": false
"use_local_pressure_in_pcxs": false,
"use_ifg_corruption_filter": true
}
}
]
Expand Down
6 changes: 4 additions & 2 deletions docs/pages/guides/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Template:
"store_binary_spectra": true,
"dc_min_threshold": 0.05,
"dc_var_threshold": 0.1,
"use_local_pressure_in_pcxs": true
"use_local_pressure_in_pcxs": true,
"use_ifg_corruption_filter": false
}
},
{
Expand All @@ -93,7 +94,8 @@ Template:
"store_binary_spectra": false,
"dc_min_threshold": 0.05,
"dc_var_threshold": 0.1,
"use_local_pressure_in_pcxs": false
"use_local_pressure_in_pcxs": false,
"use_ifg_corruption_filter": true
}
}
]
Expand Down
41 changes: 23 additions & 18 deletions src/retrieval/session/move_ifg_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,29 @@ def run(
os.path.join(dst_date_path, f"{date_string[2:]}SN.{ifg_index + 1}"),
)

# EXCLUDE CORRUPT INTERFEROGRAM FILES
# OPTIONALLY EXCLUDE CORRUPT INTERFEROGRAM FILES

try:
corrupt_filenames = list(
tum_esm_utils.interferograms.detect_corrupt_ifgs(
ifg_directory=dst_date_path
).keys()
)
except subprocess.CalledProcessError:
raise AssertionError(
"corrupt-files-detection has failed during execution"
)
if session.job_settings.use_ifg_corruption_filter:
logger.info("Using ifg corruption filter")
try:
corrupt_filenames = list(
tum_esm_utils.interferograms.detect_corrupt_ifgs(
ifg_directory=dst_date_path
).keys()
)
except subprocess.CalledProcessError:
raise AssertionError(
"corrupt-files-detection has failed during execution"
)

logger.debug(
f"Excluding {len(corrupt_filenames)} corrupt file(s) from retrieval" + (
f" ({', '.join(corrupt_filenames)})" if len(corrupt_filenames) >
0 else ""
logger.debug(
f"Excluding {len(corrupt_filenames)} corrupt file(s) from retrieval"
+ (
f" ({', '.join(corrupt_filenames)})" if len(corrupt_filenames) >
0 else ""
)
)
)
for f in corrupt_filenames:
os.remove(os.path.join(dst_date_path, f))
for f in corrupt_filenames:
os.remove(os.path.join(dst_date_path, f))
else:
logger.info("Not using ifg corruption filter")
5 changes: 5 additions & 0 deletions src/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ class RetrievalJobSettingsConfig(pydantic.BaseModel):
description=
"Whether to use the local pressure in the pcxs files. If not used, it will tell PCXS to use the pressure from the atmospheric profiles (set the input value in the `.inp` file to `9999.9`). If used, the pipeline computes the solar noon time using `skyfield` and averages the local pressure over the time period noon-2h to noon+2h.",
)
use_ifg_corruption_filter: bool = pydantic.Field(
True,
description=
"Whether to use the ifg corruption filter. This filter is a program based on `preprocess4` and is part of the `tum-esm-utils` library: https://tum-esm-utils.netlify.app/api-reference#tum_esm_utilsinterferograms. If activated, we will only pass the interferograms to the retrieval algorithm that pass the filter - i.e. that won't cause it to crash.",
)


class RetrievalJobConfig(pydantic.BaseModel):
Expand Down

0 comments on commit d659576

Please sign in to comment.