Skip to content

Commit c3c92a0

Browse files
committed
corrected processing for new bahamas data which is now one file
1 parent 251bc74 commit c3c92a0

File tree

6 files changed

+55
-52
lines changed

6 files changed

+55
-52
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ repos:
3131
description: python linter
3232
- id: ruff-format
3333
description: python formatter
34-
- repo: https://github.com/psf/black-pre-commit-mirror
35-
rev: 24.3.0
36-
hooks:
37-
- id: black-jupyter
38-
description: formating ipynb notebook
3934
- repo: https://github.com/compilerla/conventional-pre-commit
4035
rev: v3.4.0
4136
hooks:

process_config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
date: '20240827'
22
flightletter: a
33
flightname: HALO-{date}{flightletter}
4-
bahamas: ipns://latest.orcestra-campaign.org/products/HALO/position_attitude/HALO-{date}{flightletter}.zarr
4+
bahamas: ipns://latest.orcestra-campaign.org/products/HALO/position_attitude.zarr
55
radar: ipns://latest.orcestra-campaign.org/raw/HALO/radar/HALO-{date}{flightletter}/mom/*.nc
66
radiometer: ipns://latest.orcestra-campaign.org/raw/HALO/radiometer/HALO-{date}{flightletter}
77
sea_land_mask: /work/bm1183/m301049/orcestra/sea_land_mask.nc
8-
save_dir: /work/bm1183/m301049/orcestra/Hamp_Processed
8+
save_dir: /work/bm1183/m301049/orcestra/Hamp_Processed_vn2

scripts/find_amplifier_faults.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import yaml
44
from src.ipfs_helpers import read_nc
55
from src.plots_functions import plot_radiometers
6+
import matplotlib as mpl
7+
8+
mpl.use("WebAgg")
69

710
# %% load processed data
811
with open("process_config.yaml", "r") as file:

scripts/process_hamp.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626

2727
# %% define function
28-
29-
3028
def postprocess_hamp(date, flightletter, version):
3129
"""
3230
Postprocess raw data from HAMP.
@@ -67,14 +65,16 @@ def postprocess_hamp(date, flightletter, version):
6765
# load raw data
6866
print(f"Loading raw data for {date}")
6967
ds_radar_raw = read_mf_nc(paths["radar"]).load()
70-
ds_bahamas = (
71-
xr.open_dataset(paths["bahamas"], engine="zarr")
72-
.reset_coords(["lat", "lon", "alt"])
73-
.resample(time="0.25s")
74-
.mean()
75-
)
68+
7669
if date == "20240929": # only flight that crossed 0 UTC
7770
date_2 = "20240930"
71+
ds_bahamas = (
72+
xr.open_dataset(paths["bahamas"], engine="zarr")
73+
.sel(time=slice(date, date_2))
74+
.reset_coords(["lat", "lon", "alt"])
75+
.resample(time="0.25s")
76+
.mean()
77+
)
7878
ds_iwv_raw_29 = read_nc(f"{paths['radiometer']}/KV/{date[2:]}.IWV.NC")
7979
ds_iwv_raw_30 = read_nc(f"{paths['radiometer']}/KV/{date_2[2:]}.IWV.NC")
8080
ds_iwv_raw = xr.combine_by_coords(
@@ -102,6 +102,13 @@ def postprocess_hamp(date, flightletter, version):
102102
)
103103

104104
else:
105+
ds_bahamas = (
106+
xr.open_dataset(paths["bahamas"], engine="zarr")
107+
.sel(time=date)
108+
.reset_coords(["lat", "lon", "alt"])
109+
.resample(time="0.25s")
110+
.mean()
111+
)
105112
ds_iwv_raw = read_nc(f"{paths['radiometer']}/KV/{date[2:]}.IWV.NC")
106113
radiometers = ["183", "11990", "KV"]
107114
ds_radiometers_raw = {}
@@ -118,7 +125,6 @@ def postprocess_hamp(date, flightletter, version):
118125
plane_pitch=ds_bahamas["pitch"],
119126
plane_roll=ds_bahamas["roll"],
120127
plane_altitude=ds_bahamas["alt"],
121-
source=ds_bahamas.attrs["source"],
122128
)
123129
ds_iwv_lev1 = format_iwv(ds_iwv_raw).pipe(
124130
add_georeference,
@@ -127,7 +133,6 @@ def postprocess_hamp(date, flightletter, version):
127133
plane_pitch=ds_bahamas["pitch"],
128134
plane_roll=ds_bahamas["roll"],
129135
plane_altitude=ds_bahamas["alt"],
130-
source=ds_bahamas.attrs["source"],
131136
)
132137
ds_radiometers_lev1 = {}
133138
for radio in radiometers:
@@ -146,7 +151,6 @@ def postprocess_hamp(date, flightletter, version):
146151
plane_pitch=ds_bahamas["pitch"],
147152
plane_roll=ds_bahamas["roll"],
148153
plane_altitude=ds_bahamas["alt"],
149-
source=ds_bahamas.attrs["source"],
150154
)
151155

152156
sea_land_mask = xr.open_dataarray(paths["sea_land_mask"]).load()
@@ -203,9 +207,11 @@ def postprocess_hamp(date, flightletter, version):
203207

204208
# %% run postprocessing
205209
flights = pd.read_csv("flights.csv", index_col=0)
206-
version = "1.0"
210+
version = "1.1"
207211
for date, flightletter in zip(flights.index, flights["flightletter"]):
208212
postprocess_hamp(str(date), flightletter, version)
209213

214+
# %% test postprocessing
215+
postprocess_hamp("20240929", "a", "1.1")
210216

211217
# %%

scripts/testplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
fig.savefig(f"Plots/{date}_hamp_filtered.png", dpi=300)
4343

4444
# %% plot single flight
45-
date = "20240916"
45+
date = "20240929"
4646
flightletter = "a"
4747
radar = xr.open_dataset(
4848
f"{cfg['save_dir']}/radar/HALO-{date}{flightletter}_radar.zarr", engine="zarr"

src/process.py

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def _add_roll_mask(ds):
421421
return ds
422422

423423

424-
def add_georeference(ds, lat, lon, plane_pitch, plane_roll, plane_altitude, source):
424+
def add_georeference(ds, lat, lon, plane_pitch, plane_roll, plane_altitude):
425425
"""Add georeference information to dataset."""
426426
ds = ds.assign(
427427
plane_altitude=plane_altitude.sel(time=ds.time, method="nearest").assign_coords(
@@ -436,7 +436,6 @@ def add_georeference(ds, lat, lon, plane_pitch, plane_roll, plane_altitude, sour
436436
time=ds.time
437437
),
438438
)
439-
ds.attrs["georeference source"] = source
440439
return ds
441440

442441

@@ -643,23 +642,23 @@ def add_metadata_radar(ds, flight_id):
643642
"""
644643

645644
ds.attrs["flight_id"] = flight_id
646-
ds.attrs["title"] = (
647-
"MIRA Cloud Radar Moments from the HALO Microwave Package (Level 3)"
648-
)
645+
ds.attrs[
646+
"title"
647+
] = "MIRA Cloud Radar Moments from the HALO Microwave Package (Level 3)"
649648
ds.attrs["summary"] = (
650649
"This dataset contains measurements from the MIRA cloud radar onboard the HALO aircraft during the ORCESTRA campaign. "
651650
"The measurements are processed and quality controlled. The processing includes formatting the data, adding georeference information, "
652651
"filtering for noise, clutter and valid radar states, and adding masks for calibration, ground reflections, and roll segments."
653652
)
654653
ds.attrs["creator_name"] = "Jakob Deutloff, Lukas Kluft, Clara Bayley"
655-
ds.attrs["creator_email"] = (
656-
"jakob.deutloff@uni-hamburg.de, lukas.kluft@mpimet.mpg.de, clara.bayley@mpimet.mpg.de"
657-
)
654+
ds.attrs[
655+
"creator_email"
656+
] = "jakob.deutloff@uni-hamburg.de, lukas.kluft@mpimet.mpg.de, clara.bayley@mpimet.mpg.de"
658657
ds.attrs["project"] = "ORCESTRA, PERCUSION"
659658
ds.attrs["platform"] = "HALO"
660-
ds.attrs["history"] = (
661-
"The processing software is available at https://github.com/orcestra-campaign/hamp_processing"
662-
)
659+
ds.attrs[
660+
"history"
661+
] = "The processing software is available at https://github.com/orcestra-campaign/hamp_processing"
663662
ds.attrs["license"] = "CC-BY-4.0"
664663
ds.attrs["featureType"] = "trajectoryProfile"
665664
ds.attrs["references"] = "10.5194/amt-12-1815-2019, 10.5194/essd-13-5545-2021"
@@ -698,20 +697,20 @@ def add_metadata_radiometer(ds, flight_id):
698697
"adding georeference information, and filtering for altitudes above 4800 m and adding a land-sea mask."
699698
)
700699
ds.attrs["creator_name"] = "Jakob Deutloff, Lukas Kluft, Clara Bayley"
701-
ds.attrs["creator_email"] = (
702-
"jakob.deutloff@uni-hamburg.de, lukas.kluft@mpimet.mpg.de, clara.bayley@mpimet.mpg.de"
703-
)
700+
ds.attrs[
701+
"creator_email"
702+
] = "jakob.deutloff@uni-hamburg.de, lukas.kluft@mpimet.mpg.de, clara.bayley@mpimet.mpg.de"
704703
ds.attrs["project"] = "ORCESTRA, PERCUSION"
705704
ds.attrs["platform"] = "HALO"
706-
ds.attrs["history"] = (
707-
"The processing software is available at https://github.com/orcestra-campaign/hamp_processing"
708-
)
705+
ds.attrs[
706+
"history"
707+
] = "The processing software is available at https://github.com/orcestra-campaign/hamp_processing"
709708
ds.attrs["license"] = "CC-BY-4.0"
710709
ds.attrs["featureType"] = "trajectoryProfile"
711710
ds.attrs["references"] = "10.5194/amt-12-1815-2019, 10.5194/essd-13-5545-2021"
712-
ds.attrs["keywords"] = (
713-
"Radiometer, Microwave, HALO, ORCESTRA, PERCUSION, Tropical Atlantic"
714-
)
711+
ds.attrs[
712+
"keywords"
713+
] = "Radiometer, Microwave, HALO, ORCESTRA, PERCUSION, Tropical Atlantic"
715714

716715
ds.attrs.pop("Comment", None)
717716
ds.attrs.pop("Radiometer_Location", None)
@@ -739,30 +738,30 @@ def add_metadata_iwv(ds, flight_id):
739738
"""
740739

741740
ds.attrs["flight_id"] = flight_id
742-
ds.attrs["title"] = (
743-
"Integrated Water Vapor Retrieval from the K-Band and W-Band Microwave Radiometers"
744-
)
741+
ds.attrs[
742+
"title"
743+
] = "Integrated Water Vapor Retrieval from the K-Band and W-Band Microwave Radiometers"
745744
ds.attrs["summary"] = (
746745
"This dataset contains retrievals of integrated water vapor (IWV) from the KV-band microwave radiometer onboard the HALO aircraft during the ORCESTRA campaign. "
747746
"The retrieval is based on a linear regression model and should not be used for quantitative analysis. "
748747
"The purpose of this data was to provide an estimate of IWV during the flights. The processing includes formatting the data, "
749748
"adding georeference information, filtering for altitudes above 4800 m and adding a land-sea mask."
750749
)
751750
ds.attrs["creator_name"] = "Jakob Deutloff, Lukas Kluft, Clara Bayley"
752-
ds.attrs["creator_email"] = (
753-
"jakob.deutloff@uni-hamburg.de, lukas.kluft@mpimet.mpg.de, clara.bayley@mpimet.mpg.de"
754-
)
751+
ds.attrs[
752+
"creator_email"
753+
] = "jakob.deutloff@uni-hamburg.de, lukas.kluft@mpimet.mpg.de, clara.bayley@mpimet.mpg.de"
755754
ds.attrs["project"] = "ORCESTRA, PERCUSION"
756755
ds.attrs["platform"] = "HALO"
757-
ds.attrs["history"] = (
758-
"The processing software is available at https://github.com/orcestra-campaign/hamp_processing"
759-
)
756+
ds.attrs[
757+
"history"
758+
] = "The processing software is available at https://github.com/orcestra-campaign/hamp_processing"
760759
ds.attrs["license"] = "CC-BY-4.0"
761760
ds.attrs["featureType"] = "trajectoryProfile"
762761
ds.attrs["references"] = "10.5194/amt-7-4539-2014"
763-
ds.attrs["keywords"] = (
764-
"Radiometer, Microwave, Integrated Water Vapor, Retrieval, HALO, ORCESTRA, PERCUSION, Tropical Atlantic"
765-
)
762+
ds.attrs[
763+
"keywords"
764+
] = "Radiometer, Microwave, Integrated Water Vapor, Retrieval, HALO, ORCESTRA, PERCUSION, Tropical Atlantic"
766765

767766
ds.attrs.pop("Comment", None)
768767
ds.attrs.pop("Radiometer_Location", None)

0 commit comments

Comments
 (0)