Package: ncompare
ncompareCompare the structure of two NetCDF files at the command line.ncomparegenerates a view of the matching and non-matching groups and variables between two NetCDF datasets.InstallingInstall the latest version of the package from the Python Package Index (PyPI):pip install ncompareUsageTo compare two netCDF files,
pass the filepaths for each of the two netCDF files directly to ncompare, as follows:ncompare <netcdf file #1> <netcdf file #2>With an additional--file-textargument specified,
a common use ofncomparemay look like this example:ncompare S001G01.nc S001G01_SUBSET.nc --file-text subset_comparison.txtA more complete usage demonstration with example output is shown inthis example notebook.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 thecomparison_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.ContributingContributions are welcome! For more information, seeCONTRIBUTING.md.ncompareis licensed under the NASA Open Source Agreement, which is includedin this repository's license directoryandon the Open Source Initiative website.DevelopingDevelopment within this repository should occur on a feature branch.
Pull Requests (PRs) are created with a target of thedevelopbranch before being reviewed and merged.Installing locallyFor local development, one can clone the repository and then use poetry or pip from the local directory:git clone https://github.com/nasa/ncompare.git(Option A) using poetry:ii) Follow the instructions for installingpoetryhere.iii) Runpoetry installfrom the repository directory.(Option B) using pip:ii) Runpip install .from the repository directory.Testing locallyIf installed using apoetryenvironment, the tests can be run with:poetry run pytest testsOr from another virtual environment, one can use:pytest testsTo run as a locally installed poetry modulepoetry run ncompare <netcdf file #1> <netcdf file #2>Why ncompare?Thecdo(climate data operators) tooldoes not support NetCDF4 groups.
Moreover,ncooperators'ncdifffunction computes value differences, but
--- as far as the developers of this tool are aware ---ncodoes not have a simple function to show structural differences between NetCDF4 datasets.
Note thath5diff, provided in the HDF5 software, can also be used to find differences.
In comparison toh5diff,ncompareis written and runnable in Python;ncompareprovidesalignedandcolorizeddifference report for quicker assessments of groups, variable names, types, shapes, and attributes;
and can generate report files formatted for other applications. However, note thath5diffprovides comparison of some otherwise "hidden" hdf5 properties, such as _Netcdf4Dimid or _Netcdf4Coordinates,
which are not currently assessed byncompare.Known limitationsncompareusesxarrayto access the root-level dimensions.
In some cases,xarraywill miss dimensions whose names do not also exist as variable names in the dataset
(also known as non-coordinate dimensions).Some underlying HDF5 properties, such as _Netcdf4Dimid or _Netcdf4Coordinates, are not currently assesssed byncompare.Notices:Copyright 2023 United States Government as represented by the Administrator of the National Aeronautics and Space Administration.  All Rights Reserved.Third-Party Software:This software calls the following third-party software, which is subject to the terms and conditions of its licensor,
as applicable at the time of licensing. Third-party software is not bundled with this software,
but may be available from the licensor.License hyperlinks are provided here for information purposes only:itemlicenselinkcoloramaBSD-3-Clausehttps://opensource.org/licenses/BSD-3-ClausenetCDF4MIT Licensehttps://opensource.org/licenses/MITnumpyBSD-3-Clausehttps://opensource.org/licenses/BSD-3-ClauseopenpyxlMIT Licensehttps://opensource.org/licenses/MITxarrayApache License, version 2.0https://www.apache.org/licenses/LICENSE-2.0PythonStandard Library Python Software Foundation (PSF) License Agreementhttps://docs.python.org/3/license.html#psf-licenseDisclaimersNo Warranty:THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED,
OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS,
ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT,
ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED,
WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER,
CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE,
SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE.
FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE,
IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS."Waiver and Indemnity:RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT,
ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS
IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS
BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS
THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT,
TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE
REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT.