Skip to content

Commit

Permalink
Merge pull request #46 from nsidc/operations
Browse files Browse the repository at this point in the history
Simplify operations and ops docs
  • Loading branch information
mfisher87 authored Jul 23, 2024
2 parents 0c6f7e3 + beec098 commit 47d87ca
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 117 deletions.
12 changes: 12 additions & 0 deletions antarctica_today/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os

# IMPORTANT: If we don't specify this setting, then the projection we want to use will
# be replaced with another (and this warning will be printed)!
#
# Warning 1: CRS EPSG:3411 is deprecated. Its non-deprecated replacement EPSG:3413 will be
# used instead. To use the original CRS, set the OSR_USE_NON_DEPRECATED configuration
# option to NO.
# Warning 1: CRS EPSG:3412 is deprecated. Its non-deprecated replacement EPSG:3976 will be
# used instead. To use the original CRS, set the OSR_USE_NON_DEPRECATED configuration
# option to NO.
os.environ["OSR_USE_NON_DEPRECATED"] = "NO"
87 changes: 87 additions & 0 deletions antarctica_today/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import click

from antarctica_today.generate_daily_melt_file import generate_new_daily_melt_files
from antarctica_today.generate_gap_filled_melt_picklefile import (
save_gap_filled_picklefile,
)
from antarctica_today.main import (
generate_all_plots_and_maps_main,
preprocessing_main,
)
from antarctica_today.melt_array_picklefile import save_model_array_picklefile
from antarctica_today.nsidc_download_Tb_data import download_new_files


@click.group()
def cli():
"""Antarctica Today."""
pass


@click.option(
"--start-date",
default="2022-01-10",
help="TODO",
)
@cli.command()
def download_tb(start_date: str):
"""Download NSIDC-0080 brightness temperature granules.
The default start date is the day after the end of the .bin data available in
`/data/daily_melt_bin_files/` directory in this repo.
"""
download_new_files(time_start=start_date)


@click.option(
"--start-date",
# TODO: Is this default right? The actual function we're calling has a default of
# 2021-10-01. Why?
default="2022-01-10",
help="TODO",
)
@cli.command()
def generate_daily_melt(start_date: str):
"""Generate daily melt file from brightness temperature granules."""
generate_new_daily_melt_files(
start_date=start_date,
overwrite=False,
)


@cli.command
def melt_array_picklefile():
"""Is this needed operationally?"""
save_model_array_picklefile()


@cli.command
def gap_filled_melt_picklefile():
"""Is this needed operationally?"""
save_gap_filled_picklefile()


@cli.command()
def preprocess():
"""Perform pre-processing steps for Antarctica Today data.
This includes:
- ...
- ...
"""
preprocessing_main()


@cli.command()
def process():
"""Perform processing steps for Antarctica Today data.
This includes:
- ...
- ...
"""
generate_all_plots_and_maps_main()


if __name__ == "__main__":
cli()
7 changes: 4 additions & 3 deletions antarctica_today/compute_mean_climatology.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ def compute_daily_climatology_pixel_averages(

# Save out to a picklefile array.
if output_picklefile != None:
f = open(output_picklefile, "wb")
pickle.dump((average_melt_array, baseline_dates_mmdd_dict), f)
f.close()
output_picklefile.parent.mkdir(exist_ok=True, parents=True)
with open(output_picklefile, "wb") as f:
pickle.dump((average_melt_array, baseline_dates_mmdd_dict), f)

if verbose:
print(output_picklefile, "written.")

Expand Down
3 changes: 0 additions & 3 deletions antarctica_today/generate_daily_melt_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,3 @@ def create_daily_melt_array(
# output_gtif_filename=gtif_name,
# verbose=args.verbose,
# )

if __name__ == "__main__":
generate_new_daily_melt_files(overwrite=False)
4 changes: 0 additions & 4 deletions antarctica_today/generate_gap_filled_melt_picklefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,3 @@ def fill_melt_array_with_interpolations(array=None, datetimes_dict=None, verbose
# print("\t", "Day missing, fill with mean. Average:", numpy.sum(day_slice[day_slice!=-1]))

return gap_filled_array, gap_filled_dt_dict


if __name__ == "__main__":
save_gap_filled_picklefile()
32 changes: 0 additions & 32 deletions antarctica_today/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,3 @@ def generate_all_plots_and_maps_main():
# outfile = fname_svg)

# # TODO: Finish if you want.


@click.group()
def cli():
"""Antarctica Today."""
pass


@cli.command()
def preprocess():
"""Perform pre-processing steps for Antarctica Today data.
This includes:
- ...
- ...
"""
preprocessing_main()


@cli.command()
def process():
"""Perform processing steps for Antarctica Today data.
This includes:
- ...
- ...
"""
generate_all_plots_and_maps_main()


if __name__ == "__main__":
cli()
5 changes: 0 additions & 5 deletions antarctica_today/melt_array_picklefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,3 @@ def read_gap_filled_melt_picklefile(
array, dt_dict = pickle.load(f)

return array, dt_dict


if __name__ == "__main__":
# Let's save the v2.5 data from Tom's stuff.
array, dt_dict = save_model_array_picklefile()
5 changes: 0 additions & 5 deletions antarctica_today/nsidc_download_Tb_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,3 @@ def download_new_files(
quit()

return files_saved


if __name__ == "__main__":
# By default, start the following day after the .bin files end in the /data/daily_melt_bin_files/ directory.
download_new_files(time_start="2022-01-10")
Loading

0 comments on commit 47d87ca

Please sign in to comment.