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

Add reading grib files for stats #33

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
3ec8155
added grib_parser
Jul 18, 2024
ae3a747
eccodes_definition in setup_env
Jul 19, 2024
56ab73e
applied changes for reading grib files
andleuth Jul 29, 2024
b3bc25e
Formatting
andleuth Jul 29, 2024
fd39159
update to master branch
andleuth Jul 30, 2024
3250783
dummy change
andleuth Jul 30, 2024
940f1f9
revert dummy change
andleuth Jul 30, 2024
fce5ac0
adapt get_ds()
andleuth Aug 5, 2024
b046756
unitest and change in grib_definition_path
andleuth Aug 7, 2024
dde8b24
old def_path for safety
andleuth Aug 7, 2024
ea0e431
Merge remote-tracking branch 'origin/main' into reading_grib_files
huppd Oct 1, 2024
6546223
improve formatting
huppd Oct 1, 2024
d3a942e
frist draft tests
huppd Oct 1, 2024
f62a22a
add unittest
huppd Oct 1, 2024
35e9821
rm deleted files
huppd Oct 1, 2024
c72eb96
update requirements
huppd Oct 1, 2024
5048f49
update requirements
huppd Oct 1, 2024
e2f426e
Merge branch 'reading_grib_files' of github.com:MeteoSwiss/probtest i…
huppd Oct 2, 2024
f9d04a9
use pinned version for ci and make python version consistent
huppd Oct 2, 2024
145dd49
pin env and set python version
huppd Oct 2, 2024
7dd8c18
add author
huppd Oct 2, 2024
e450ff7
fix gitignore
huppd Oct 2, 2024
cb5d76c
update gitignore
huppd Oct 2, 2024
13ce70c
small improvement
huppd Oct 3, 2024
7be1ac4
change to pytest
huppd Oct 3, 2024
99320d8
cleanup tmp path
huppd Oct 3, 2024
92677de
fix tmp
huppd Oct 3, 2024
658c249
cleanup gitignore
huppd Oct 3, 2024
32a180b
fix utest
huppd Oct 4, 2024
c16e221
fix env
huppd Oct 4, 2024
d2d84d3
improve github actions
huppd Oct 4, 2024
4f7e183
fix env
huppd Oct 4, 2024
74ad301
step by step refactor
huppd Oct 4, 2024
3996217
next step
huppd Oct 4, 2024
3b467e5
next step
huppd Oct 4, 2024
30bbcd3
next step
huppd Oct 4, 2024
bc0be67
last step
huppd Oct 4, 2024
b5c2866
last step
huppd Oct 4, 2024
7c59155
Merge branch 'reading_grib_files' of github.com:MeteoSwiss/probtest i…
huppd Oct 4, 2024
ad6e44e
cleanup gitignore
huppd Oct 4, 2024
8b074d7
minor change
huppd Oct 4, 2024
7e1427b
fix readme
huppd Oct 4, 2024
3f9bd0d
fix definitions version
huppd Oct 4, 2024
8f89c85
make icon consistent
huppd Oct 4, 2024
6039666
fix naming
huppd Oct 4, 2024
7bfcea5
fix naming
huppd Oct 4, 2024
903f8a4
fix eccodes version
huppd Oct 4, 2024
d9a1797
inlcude sample path
huppd Oct 4, 2024
a584fca
use eccodes=2.35.0
huppd Oct 4, 2024
59a0833
fix python version
huppd Oct 7, 2024
21c6d24
might not be needed
huppd Oct 7, 2024
c357b92
Merge remote-tracking branch 'origin/main' into reading_grib_files
huppd Oct 8, 2024
8000bdf
revert hotfix
huppd Oct 8, 2024
f2ab296
Merge remote-tracking branch 'origin/main' into reading_grib_files
huppd Oct 15, 2024
43a3985
update README.md
huppd Oct 16, 2024
2ed2845
refactor
huppd Oct 16, 2024
586d5a1
use closets possiblle eccodes to 2.25.0
huppd Oct 16, 2024
9b94a3a
refactor
huppd Oct 16, 2024
f51fcd4
not so nice workaround
huppd Oct 16, 2024
e50ec27
workaround
huppd Oct 17, 2024
427a954
update env
huppd Nov 7, 2024
68ee283
rename var
huppd Nov 7, 2024
0a2fc58
fix name
huppd Nov 7, 2024
282a9d3
rm mamba option
huppd Nov 8, 2024
937184e
fix name
huppd Nov 8, 2024
4321bbc
update requirements
huppd Nov 8, 2024
8ca9638
update eccodes, needs test fixing
huppd Nov 22, 2024
a438460
fix environment
huppd Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
.idea*
.vscode
*pycache*
Expand All @@ -6,12 +7,9 @@
*.png
*.log
*.nc
.coverage
coverage.xml
miniconda

# output from unittest
test_stats.csv
test_stats_csv.csv
test_stats_csv.dat
# output from pytest
random_tolerance.csv
random_tolerance_None.csv
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| Marek Jacob | DWD |
| Jonas Jucker | C2SM |
| Annika Lauber | C2SM |
| Andrea Leuthard | MeteoSwiss |
| Giacomo Serafini | MeteoSwiss |
| Mikael Stellio | C2SM |
| Ben Weber | MeteoSwiss |
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ The pinned requirements can be installed by
```console
./setup_env.sh
```
which is recommended for users.

The unpinned requirements and updating the environment can be done by
```console
./setup_env.sh -u -e
```
which is recommended for developers and required for adding new requirements.


### The init command
Expand Down Expand Up @@ -138,7 +141,17 @@ here should refer to your experiment script:

```console
cd icon-base-dir/reference-build
python ../externals/probtest/probtest.py init --codebase-install $PWD --experiment-name exp_name --reference $PWD --file-id NetCDF "*atm_3d_ml*.nc" --file-id NetCDF "*atm_3d_il*.nc" --file-id NetCDF "*atm_3d_hl*.nc" --file-id NetCDF "*atm_3d_pl*.nc" --file-id latlon "*atm_2d_ll*.nc" --file-id meteogram "Meteogram*.nc"
python ../externals/probtest/probtest.py init \
--codebase-install $PWD \
--experiment-name exp_name \
--reference $PWD \
--file-id NetCDF "*atm_3d_ml*.nc" \
--file-id NetCDF "*atm_3d_il*.nc" \
--file-id NetCDF "*atm_3d_hl*.nc" \
--file-id NetCDF "*atm_3d_pl*.nc" \
--file-id latlon "*atm_2d_ll*.nc" \
--file-id meteogram "Meteogram*.nc" \
--file-id GRIB "lfff0*z"
```
You might need to update the used account in the json file.
The perturbation amplitude may also need to be changed in the json file
Expand Down
12 changes: 6 additions & 6 deletions engine/cdo_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from util.click_util import CommaSeperatedInts, cli_help
from util.constants import cdo_bins
from util.dataframe_ops import df_from_file_ids
from util.file_system import file_names_from_pattern
from util.file_system import get_file_names_from_pattern
from util.log_handler import logger


Expand Down Expand Up @@ -139,21 +139,21 @@ def cdo_table(
assert isinstance(file_specification, dict), "must be dict"

# save original method and restore at the end of this module
dataframe_from_ncfile_orig = model_output_parser.dataframe_from_ncfile
dataframe_from_ncfile_orig = model_output_parser.create_statistics_dataframe
# modify netcdf parse method:
model_output_parser.dataframe_from_ncfile = rel_diff_stats
model_output_parser.create_statistics_dataframe = rel_diff_stats

# step 1: compute rel-diff netcdf files
with tempfile.TemporaryDirectory() as tmpdir:
for _, file_pattern in file_id:
ref_files, err = file_names_from_pattern(model_output_dir, file_pattern)
ref_files, err = get_file_names_from_pattern(model_output_dir, file_pattern)
if err > 0:
logger.info(
"did not find any files for pattern %s. Continue.", file_pattern
)
continue
ref_files.sort()
perturb_files, err = file_names_from_pattern(
perturb_files, err = get_file_names_from_pattern(
perturbed_model_output_dir.format(member_id=member_id), file_pattern
)
if err > 0:
Expand Down Expand Up @@ -202,4 +202,4 @@ def cdo_table(

Path(cdo_table_file).parent.mkdir(parents=True, exist_ok=True)
df.to_csv(cdo_table_file)
model_output_parser.dataframe_from_ncfile = dataframe_from_ncfile_orig
model_output_parser.create_statistics_dataframe = dataframe_from_ncfile_orig
6 changes: 4 additions & 2 deletions engine/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import click

from util.click_util import cli_help
from util.file_system import file_names_from_pattern
from util.file_system import get_file_names_from_pattern
from util.icon.extract_timings import read_logfile
from util.log_handler import logger
from util.tree import TREEFILE_TEMPLATE, TimingTree
Expand All @@ -36,7 +36,9 @@ def performance(timing_regex, timing_database, append_time):
if timing_file_name_base == "":
timing_file_name_base = "."

timing_file_name, err = file_names_from_pattern(timing_file_name_base, timing_regex)
timing_file_name, err = get_file_names_from_pattern(
timing_file_name_base, timing_regex
)
if err > 0:
logger.info("Did not find any files for regex %s", timing_regex)
sys.exit(1)
Expand Down
Loading
Loading