Skip to content

Commit cc40550

Browse files
authored
Updated libraries and tests so that everything is passing (#9)
1 parent 90e9a59 commit cc40550

11 files changed

+408
-580
lines changed

CHANGELOG.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Changed
9+
- Project migrated to https://github.com/podaac/net2cog
810

11+
## [0.2.0-alpha.15] - 26 July 2023
912
### Added
1013
- PCESA-2309 - Implemented the harmony-service-lib interface so that I can be run in the Harmony ngap account
1114
### Changed
12-
- PCESA-2309 - Updated Jenkins to include building and pushing to ECC_NEXUS
13-
### Deprecated
14-
### Removed
15-
### Fixed
16-
### Security
15+
- PCESA-2309 - Updated Jenkins to include building and pushing to ECC_NEXUS
1716

1817
## [0.2.0-alpha.14] - 3 September 2020
1918
### Changed
File renamed without changes.

podaac/netcdf_converter/netcdf_convert.py renamed to net2cog/netcdf_convert.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
"""
99

1010
import os
11+
import pathlib
1112
from os.path import join as pjoin, basename, dirname, exists, splitext
1213
import subprocess
1314
from subprocess import check_call
1415

1516
import logging
1617
import tempfile
18+
from typing import List
19+
1720
import xarray as xr
1821
import rasterio
1922
import rasterio.crs
@@ -61,7 +64,7 @@ def get_gtiff_name(output_file):
6164
out_fname = pjoin(dir_path, rel_path)
6265
if not exists(out_fname):
6366
os.makedirs(out_fname)
64-
return out_fname
67+
return pjoin(out_fname, rel_path)
6568

6669

6770
def _write_cogtiff(out_f_name, nc_xarray):
@@ -135,31 +138,22 @@ def rioxr_swapdims(netcdf_xarray):
135138
dst_profile = cog_profiles.get("deflate")
136139
cog_translate(src_dst, out_fname, dst_profile)
137140

138-
# cog validation method
139-
# cogtif_val = [
140-
# 'rio',
141-
# 'cogeo',
142-
# 'validate',
143-
# out_fname
144-
# ]
145-
# run_command(cogtif_val, dirname(out_f_name))
146-
147141
cogs_generated.append(out_fname)
148142
LOGGER.info("Finished conversion, writing variable: %s", out_fname)
149143
LOGGER.info("NetCDF conversion complete. Returning COGs generated.")
150144
return cogs_generated
151145

152146

153-
def netcdf_converter(input_nc_file, output_cog_pathname, var_list=None):
147+
def netcdf_converter(input_nc_file: pathlib.Path, output_cog_pathname: pathlib.Path, var_list: list = ()) -> List[str]:
154148
"""
155149
Primary function for beginning NetCDF conversion using rasterio,
156150
rioxarray and xarray
157151
158152
Parameters
159153
----------
160-
input_nc_file : string
154+
input_nc_file : pathlib.Path
161155
Path to NetCDF file to process
162-
output_cog_pathname : string
156+
output_cog_pathname : pathlib.Path
163157
COG Output path and NetCDF filename, filename converted to cog variable
164158
filename (.tif)
165159
ex: tests/data/tmpygj2vgxf/
@@ -189,7 +183,7 @@ def netcdf_converter(input_nc_file, output_cog_pathname, var_list=None):
189183
# used to invert y axis
190184
# xds_reversed = xds.reindex(lat=xds.lat[::-1])
191185
LOGGER.info("Writing COG to %s", basename(gtiff_fname))
192-
if var_list is not None and var_list != '':
186+
if var_list:
193187
xds = xds[var_list]
194188
return _write_cogtiff(gtiff_fname, xds)
195189
LOGGER.error("%s: NetCDF file does not contain spatial dimensions such as lat / lon "

podaac/netcdf_converter/netcdf_convert_harmony.py renamed to net2cog/netcdf_convert_harmony.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@
1313
import pathlib
1414

1515
import harmony
16-
import harmony.util
17-
from harmony import BaseHarmonyAdapter
1816

19-
from podaac.netcdf_converter import netcdf_convert
17+
from net2cog import netcdf_convert
2018

2119
DATA_DIRECTORY_ENV = "DATA_DIRECTORY"
2220

2321

24-
class NetcdfConverterService(BaseHarmonyAdapter):
22+
class NetcdfConverterService(harmony.BaseHarmonyAdapter):
2523
"""
26-
See https://git.earthdata.nasa.gov/projects/HARMONY/repos/harmony-service-lib-py/browse
24+
See https://github.com/nasa/harmony-service-lib-py
2725
for documentation and examples.
2826
"""
2927

podaac/netcdf_converter/netcdf_convert_worker.py

Lines changed: 0 additions & 140 deletions
This file was deleted.

0 commit comments

Comments
 (0)