Skip to content

Commit

Permalink
Merge pull request #279 from nasa/release/1.12.0
Browse files Browse the repository at this point in the history
Release/1.12.0
  • Loading branch information
danielfromearth authored Dec 20, 2024
2 parents 4ac0166 + 7fbe5d6 commit 75e36c5
Show file tree
Hide file tree
Showing 17 changed files with 905 additions and 640 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ repos:
exclude_types: ["jupyter", "text"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.8.1
hooks:
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Common Changelog](https://common-changelog.org/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.12.0] - 2024-12-20

### Changed

- Clean up docstrings, especially removing types that are already annotated in function signature ([#274](https://github.com/nasa/ncompare/issues/274)) ([**@danielfromearth**](https://github.com/danielfromearth))

### Added

- Categorize counts of differences (including attributes) in a summary ([#276](https://github.com/nasa/ncompare/pull/276)) ([**@danielfromearth**](https://github.com/danielfromearth))
- Include dimensions in variable attribute comparisons ([#277](https://github.com/nasa/ncompare/pull/277)) ([**@danielfromearth**](https://github.com/danielfromearth))
- Provide numerical output where zero means no differences found ([#278](https://github.com/nasa/ncompare/pull/278)) ([**@danielfromearth**](https://github.com/danielfromearth))

### Removed

- **Breaking:** drop support for randomized value checks, which are no longer part of API ([#271](https://github.com/nasa/ncompare/pull/271)) ([**@danielfromearth**](https://github.com/danielfromearth))

### Fixed

- Catch "unsupported datatype" exception from netCDF library ([#268](https://github.com/nasa/ncompare/pull/268)) ([**@danielfromearth**](https://github.com/danielfromearth))

## [1.11.0] - 2024-11-14

### Added
Expand Down
48 changes: 20 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,27 @@ _____
<img src="https://joss.theoj.org/papers/10.21105/joss.06490/status.svg" alt="DOI badge" >
</a>

Compare the structure of two NetCDF files at the command line.
Compare the structure of two NetCDF files at the command line or via Python.
`ncompare` generates a view of the matching and non-matching groups and variables between two NetCDF datasets.


## Installing

The latest release of `ncompare` can be installed with `mamba`, `conda` or `pip`.

#### Using `mamba`
The latest release of `ncompare` can be installed with `mamba`, `conda` or `pip`:

```bash
mamba install -c conda-forge ncompare
```

#### Using `conda`

```bash
conda install -c conda-forge ncompare
```

#### Using `pip`

```bash
pip install ncompare
```

## Usage
## Usage Examples

### At a command line:
To compare two netCDF files,
pass the filepaths for each of the two netCDF files directly to ncompare, as follows:

Expand All @@ -77,23 +70,22 @@ a common use of _ncompare_ may look like this example:
ncompare S001G01.nc S001G01_SUBSET.nc --file-text subset_comparison.txt
```

**A more complete usage demonstration with example output is shown in
[this example notebook](https://ncompare.readthedocs.io/en/latest/example/ncompare-example-usage/).**

### Options

- `-h`, `--help` : Show this help message and exit.
- `--file-text` [FILE_PATH]: Text file to write output to.
- `--file-csv` [FILE_PATH]: Comma-separated values (CSV) file to write output to.
- `--file-xlsx` [FILE_PATH]: Excel file to write output to.
- `--only-diffs` : Only display variables and attributes that are different
- `--no-color` : Turn off all colorized output.
- `--show-attributes` : Include variable attributes in the table that compares variables.
- `--show-chunks` : Include chunk sizes in the table that compares variables.
- `-v` (`--comparison_var_name`) [VAR_NAME]: Compare specific values for this variable.
- `-g` (`--comparison_var_group`) [VAR_GROUP]: Group that contains the `comparison_var_name`.
- `--column-widths` [WIDTH, WIDTH, WIDTH]: Width, in number of characters, of the three columns in the comparison report
- `--version` : Show the current version and then exit.
### In a Python kernel:

```python
from ncompare import compare

total_number_of_differences = compare(
"<netcdf file 1>",
"<netcdf file 2>",
only_diffs=True,
show_attributes=True,
show_chunks=True,
)
```


### More complete usage demonstrations, with example output, are shown in [this example notebook](https://ncompare.readthedocs.io/en/latest/example/ncompare-example-usage/).

## Contributing

Expand Down
386 changes: 349 additions & 37 deletions docs/example/ncompare-example-usage.ipynb

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions ncompare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@
# See the License for the specific language governing permissions and limitations under the License.

"""Main code for comparing NetCDF files."""

from importlib.metadata import version

from .core import (
compare,
)

__all__ = [
"compare",
]

__version__ = version("ncompare")
9 changes: 4 additions & 5 deletions ncompare/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ def _cli(args: Optional[Sequence[str]]) -> argparse.Namespace:
Parameters
----------
args : None or list[str]
if None, then argparse will use sys.argv[1:]
args
if None, then argparse will use `sys.argv[1:]`
"""
parser = argparse.ArgumentParser(
description="Compare the variables contained within two different NetCDF datasets"
)
parser.add_argument("nc_a", help="First NetCDF file")
parser.add_argument("nc_b", help="Second NetCDF file")
parser.add_argument("-v", "--comparison_var_name", help="Comparison variable name")
parser.add_argument("-g", "--comparison_var_group", help="Comparison variable group")
parser.add_argument(
"--only-diffs",
action="store_true",
Expand Down Expand Up @@ -110,10 +108,11 @@ def main() -> None: # pragma: no cover
delattr(args, "version")

try:
compare(**vars(args))
total_diff_count = compare(**vars(args))
except Exception: # pylint: disable=broad-exception-caught
print(traceback.format_exc())
sys.exit(1)
print(total_diff_count)
sys.exit(0) # a clean, no-issue, exit


Expand Down
Loading

0 comments on commit 75e36c5

Please sign in to comment.