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

Fix default AWIPS tiled _FillValue of -1 for newer versions of xarray #2858

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
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 satpy/writers/awips_tiled.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python

Check notice on line 1 in satpy/writers/awips_tiled.py

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Lines of Code in a Single File

The lines of code decreases from 1242 to 1240, improve code health by reducing it to 600. The number of Lines of Code in a single file. More Lines of Code lowers the code health.
# -*- coding: utf-8 -*-
# Copyright (c) 2017-2018 Satpy developers
#
Expand Down Expand Up @@ -626,7 +626,7 @@
fills = [2 ** file_bit_depth - 1]
elif unsigned_in_signed:
# max unsigned value is -1 as a signed int
fills = [-1]
fills = [dtype.type(-1)]
else:
# max value
fills = [2 ** (file_bit_depth - 1) - 1]
Expand Down Expand Up @@ -1063,12 +1063,10 @@
new_ds.coords["x"].encoding["dtype"] = "int16"
new_ds.coords["x"].encoding["scale_factor"] = np.float64(xy_factors.mx)
new_ds.coords["x"].encoding["add_offset"] = np.float64(xy_factors.bx)
new_ds.coords["x"].encoding["_FillValue"] = -1
if "y" in new_ds.coords:
new_ds.coords["y"].encoding["dtype"] = "int16"
new_ds.coords["y"].encoding["scale_factor"] = np.float64(xy_factors.my)
new_ds.coords["y"].encoding["add_offset"] = np.float64(xy_factors.by)
new_ds.coords["y"].encoding["_FillValue"] = -1
return new_ds

def apply_tile_info(self, new_ds, tile_info):
Expand Down Expand Up @@ -1102,7 +1100,7 @@
if creator is None:
creator = "Satpy Version {} - AWIPS Tiled Writer".format(__version__)
if creation_time is None:
creation_time = dt.datetime.utcnow()
creation_time = dt.datetime.now(dt.timezone.utc)

Check warning on line 1103 in satpy/writers/awips_tiled.py

View check run for this annotation

Codecov / codecov/patch

satpy/writers/awips_tiled.py#L1103

Added line #L1103 was not covered by tests

self._add_sector_id_global(new_ds, sector_id)
new_ds.attrs["Conventions"] = "CF-1.7"
Expand Down Expand Up @@ -1598,7 +1596,7 @@
area_data_arrs = self._group_by_area(datasets)
datasets_to_save = []
output_filenames = []
creation_time = dt.datetime.utcnow()
creation_time = dt.datetime.now(dt.timezone.utc)
area_tile_data_gen = self._iter_area_tile_info_and_datasets(
area_data_arrs, template, lettered_grid, sector_id, num_subtiles,
tile_size, tile_count, use_sector_reference)
Expand Down
Loading