Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.0 #104

Merged
merged 54 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
caa7cf2
#105 Add DC amplitudes and variance to output (1)
dostuffthatmatters Sep 10, 2024
bc4d8ae
#105 Add DC amplitudes and variance to output (2)
dostuffthatmatters Sep 10, 2024
37d2efa
#105 Add DC amplitudes and variance to output (3)
dostuffthatmatters Sep 10, 2024
737a92a
#105 Add DC amplitudes and variance to output (4)
dostuffthatmatters Sep 10, 2024
cd63c29
#105 Add DC amplitudes and variance to output (5)
dostuffthatmatters Sep 10, 2024
706c10f
#105 Add DC amplitudes and variance to output (6)
dostuffthatmatters Sep 10, 2024
7f31b6f
#105 Add DC amplitudes and variance to output (7)
dostuffthatmatters Sep 10, 2024
159a6d5
#105 Add DC amplitudes and variance to output (8)
dostuffthatmatters Sep 10, 2024
c0fb7ed
#97 Support different ground pressure file formats (1)
dostuffthatmatters Sep 11, 2024
d22040a
Increase column limit for YAPF formatting
dostuffthatmatters Sep 11, 2024
3f86316
#102 Make Interferogram File Regex more flexible (1)
dostuffthatmatters Sep 11, 2024
63f0572
Use `sys.executable` instead of `.venv/bin/python` to run retrievals
dostuffthatmatters Sep 11, 2024
8292740
#102 Make Interferogram File Regex more flexible (2)
dostuffthatmatters Sep 11, 2024
c28fc1e
#97 Support different ground pressure file formats (2)
dostuffthatmatters Sep 11, 2024
84c8f21
#97 Support different ground pressure file formats (3)
dostuffthatmatters Sep 11, 2024
583f936
#97 Support different ground pressure file formats (4)
dostuffthatmatters Sep 11, 2024
3709605
#97 Support different ground pressure file formats (5)
dostuffthatmatters Sep 11, 2024
7d2a5fa
Update reporting with new pressure logic (#97) and Proffast 2.4
dostuffthatmatters Sep 11, 2024
67c57ca
#103 Disallow extra keys on dicts with optional keys
dostuffthatmatters Sep 11, 2024
6647ec1
#97 Support different ground pressure file formats (6)
dostuffthatmatters Sep 11, 2024
9d1da95
#97 Support different ground pressure file formats (7)
dostuffthatmatters Sep 11, 2024
f360151
#97 Support different ground pressure file formats (8)
dostuffthatmatters Sep 11, 2024
2c7d20d
#97 Support different ground pressure file formats (9)
dostuffthatmatters Sep 11, 2024
847b8ef
#97 Support different ground pressure file formats (10)
dostuffthatmatters Sep 11, 2024
5a04dd3
#101 Refactor export (1)
dostuffthatmatters Sep 12, 2024
23234ca
#101 Refactor export (2)
dostuffthatmatters Sep 12, 2024
3371a67
#101 Refactor export (3)
dostuffthatmatters Sep 12, 2024
1dce903
Format pytest files (with increased column limit)
dostuffthatmatters Sep 12, 2024
b092fe6
#101 Refactor export (4)
dostuffthatmatters Sep 12, 2024
6914978
#101 Refactor export (5)
dostuffthatmatters Sep 12, 2024
aeb0e59
#101 Refactor export (6)
dostuffthatmatters Sep 12, 2024
02d81e9
#101 Refactor export (7)
dostuffthatmatters Sep 12, 2024
e3fc4ad
#101 Refactor export (8)
dostuffthatmatters Sep 12, 2024
e4f3759
#101 Refactor export (9)
dostuffthatmatters Sep 12, 2024
905de84
#101 Refactor export (10)
dostuffthatmatters Sep 12, 2024
ec08821
#101 Refactor export (11)
dostuffthatmatters Sep 12, 2024
0c4099b
#101 Refactor export (12)
dostuffthatmatters Sep 12, 2024
9419735
#101 Refactor export (13)
dostuffthatmatters Sep 12, 2024
48dd035
#101 Refactor export (14)
dostuffthatmatters Sep 12, 2024
6e1f804
#101 Refactor export (15)
dostuffthatmatters Sep 12, 2024
171856a
#101 Refactor export (16)
dostuffthatmatters Sep 12, 2024
e69df34
#101 Refactor export (17)
dostuffthatmatters Sep 13, 2024
7030eeb
#101 Refactor export (18)
dostuffthatmatters Sep 13, 2024
448fc54
#101 Refactor export (19)
dostuffthatmatters Sep 13, 2024
2876cc7
Move utilities to `tum_esm_utils` (1)
dostuffthatmatters Sep 13, 2024
ea3b0e8
Move utilities to `tum_esm_utils` (2)
dostuffthatmatters Sep 13, 2024
9159504
Move utilities to `tum_esm_utils` (3)
dostuffthatmatters Sep 13, 2024
a38d4c2
#101 Refactor export (20)
dostuffthatmatters Sep 17, 2024
8c93bb0
#60 Remove calibration from metadata (1)
dostuffthatmatters Sep 17, 2024
41a1be3
#60 Remove calibration from metadata (2)
dostuffthatmatters Sep 17, 2024
d2c46f9
Make the retrieval queue easier to understand/debug
dostuffthatmatters Sep 17, 2024
4eaba0a
Update API reference
dostuffthatmatters Sep 17, 2024
a5426d7
Close #99
dostuffthatmatters Sep 17, 2024
b4980d3
Debug test data downloading
dostuffthatmatters Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
61 changes: 17 additions & 44 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import click
import em27_metadata

_RETRIEVAL_ENTRYPOINT = tum_esm_utils.files.rel_to_abs_path(
"src", "retrieval", "main.py"
)
_RETRIEVAL_ENTRYPOINT = tum_esm_utils.files.rel_to_abs_path("src", "retrieval", "main.py")

cli = click.Group(name="cli")
retrieval_command_group = click.Group(name="retrieval")
profiles_command_group = click.Group(name="profiles")
export_command_group = click.Group(name="export")
bundle_command_group = click.Group(name="bundle")


def _check_config_validity() -> None:
Expand All @@ -23,16 +21,10 @@ def _check_config_validity() -> None:
click.echo(click.style("Config is valid", fg="green", bold=True))
except pydantic.ValidationError as e:
click.echo(
click.style(
f"Detected {e.error_count()} error(s) in the config:",
bold=True,
fg="red"
)
click.style(f"Detected {e.error_count()} error(s) in the config:", bold=True, fg="red")
)
for error in e.errors():
loc = click.style(
'.'.join([str(l) for l in error['loc']]) + ":", bold=True
)
loc = click.style('.'.join([str(l) for l in error['loc']]) + ":", bold=True)
click.echo(f" - {loc} {error['msg']}")
exit(1)

Expand All @@ -43,15 +35,12 @@ def _check_config_validity() -> None:
"Start the retrieval as a background process. Prevents spawning multiple processes. The logs and the current processing queue from this process can be found at `logs/retrieval`.",
)
@click.option(
"--watch",
is_flag=True,
default=False,
help="Start the watcher after starting the process."
"--watch", is_flag=True, default=False, help="Start the watcher after starting the process."
)
def start(watch: bool) -> None:
_check_config_validity()
pid = tum_esm_utils.processes.start_background_process(
sys.executable, _RETRIEVAL_ENTRYPOINT
sys.executable, _RETRIEVAL_ENTRYPOINT, waiting_period=0.125
)
click.echo(f"Started automated retrieval background process with PID {pid}")

Expand Down Expand Up @@ -114,18 +103,10 @@ def stop() -> None:
)
def download_algorithms() -> None:
import src
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast10_code(
click.echo
)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast22_code(
click.echo
)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast23_code(
click.echo
)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast24_code(
click.echo
)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast10_code(click.echo)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast22_code(click.echo)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast23_code(click.echo)
src.retrieval.dispatching.container_factory.ContainerFactory.init_proffast24_code(click.echo)


@profiles_command_group.command(
Expand Down Expand Up @@ -159,21 +140,15 @@ def request_ginput_status() -> None:
) as ftp:
with io.BytesIO(config.profiles.server.email.encode("utf-8")) as f:
ftp.storbinary(f"STOR upload/ginput_status.txt", f)
click.echo(
f"Requested ginput status for email address {config.profiles.server.email}"
)
click.echo(f"Requested ginput status for email address {config.profiles.server.email}")


@export_command_group.command(
name="run",
help=
"Run the export script. The logs from this process can be found at `logs/export`.",
)
def run_export() -> None:
@bundle_command_group.command(name="run", help="Create a bundle of your entire retrieval dataset")
def run_bundle() -> None:
_check_config_validity()

import src # import here so that the CLI is more reactive
src.export.main.run()
src.bundle.main.run()


@cli.command(
Expand All @@ -192,8 +167,7 @@ def print_data_report() -> None:

# load metadata interface
console.print("Loading metadata")
em27_metadata_interface = src.utils.metadata.load_local_em27_metadata_interface(
)
em27_metadata_interface = src.utils.metadata.load_local_em27_metadata_interface()
if em27_metadata_interface is not None:
print("Found local metadata")
else:
Expand All @@ -206,8 +180,7 @@ def print_data_report() -> None:
print("Successfully fetched metadata from GitHub")

console.print(
f"Printing report for the data paths: " +
config.general.data.model_dump_json(indent=4)
f"Printing report for the data paths: " + config.general.data.model_dump_json(indent=4)
)
try:
src.utils.report.export_data_report(
Expand All @@ -221,7 +194,7 @@ def print_data_report() -> None:

cli.add_command(retrieval_command_group)
cli.add_command(profiles_command_group)
cli.add_command(export_command_group)
cli.add_command(bundle_command_group)

if __name__ == "__main__":
cli()
34 changes: 23 additions & 11 deletions config/config.template.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"version": "1.3",
"version": "1.4",
"general": {
"metadata": {
"github_repository": "tum-esm/em27-metadata-storage",
"access_token": null
},
"data": {
"datalogger": "path-to-datalogger-upload-directory",
"ground_pressure": {
"path": "path-to-ground-pressure-data",
"file_regex": "^$(SENSOR_ID)$(DATE).*\\.csv$",
"separator": ",",
"pressure_column": "pressure",
"pressure_column_format": "hPa",
"date_column": "UTCdate_____",
"date_column_format": "%Y-%m-%d",
"time_column": "UTCtime_____",
"time_column_format": "%H:%M:%S"
},
"atmospheric_profiles": "path-to-atmospheric-profiles",
"interferograms": "path-to-ifg-upload-directory",
"results": "path-to-results-storage"
Expand Down Expand Up @@ -35,7 +45,8 @@
"retrieval": {
"general": {
"max_process_count": 9,
"ifg_file_regex": "^$(SENSOR_ID)$(DATE).*\\.\\d+$"
"ifg_file_regex": "^$(SENSOR_ID)$(DATE).*\\.\\d+$",
"queue_verbosity": "compact"
},
"jobs": [
{
Expand Down Expand Up @@ -70,15 +81,16 @@
}
]
},
"export_targets": [
"bundles": [
{
"campaign_id": "muccnet",
"retrieval_algorithm": "proffast-2.3",
"atmospheric_profile_model": "GGG2020",
"data_types": ["gnd_p", "gnd_t", "app_sza", "azimuth", "xh2o", "xair", "xco2", "xch4", "xco", "xch4_s5p"],
"sampling_rate": "1m",
"max_interpolation_gap_seconds": 180,
"dst_dir": "path-to-merged-output"
"dst_dir": "directory-to-write-the-bundles-to",
"output_formats": ["csv", "parquet"],
"from_datetime": "2022-01-01T00:00:00Z",
"to_datetime": "2022-12-31T23:59:59Z",
"retrieval_algorithms": ["proffast-1.0", "proffast-2.4"],
"atmospheric_profile_models": ["GGG2014", "GGG2020"],
"sensor_ids": ["ma", "mb", "mc", "md", "me"],
"parse_dc_timeseries": true
}
]
}
2 changes: 2 additions & 0 deletions data/testing/bundle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
outputs/*
!outputs/.gitkeep
File renamed without changes.
4 changes: 2 additions & 2 deletions data/testing/container/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
inputs
outputs/*
outputs/*
!outputs/.gitkeep
1 change: 1 addition & 0 deletions data/testing/inputs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All the data required to run and test the pipeline is stored inside the repository - with the exception of the interferogram files, because they would add ~ 122MB of data to the repository. The pytests download these interferograms automatically. The test interferograms can be manually downloaded from https://syncandshare.lrz.de/getlink/fiDWAwmdQubVDviAoN1uoc/em27-retrieval-pipeline-test-interferograms-2024-09-12.tar.gz.
4 changes: 4 additions & 0 deletions data/testing/inputs/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ifg/*
!ifg/.gitkeep
!*.csv
!*.map
Loading