Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Help!

32 views
Skip to first unread message

Asheesh Bhattarai

unread,
Jul 16, 2024, 4:31:37 PM7/16/24
to pytroll
Hi all,
I am having issues to write the resampled file in nc format using satpy. If anyone is familiar with this error, please help me! 
I am working with GOES-16 ABI L2 data products. I resampled and changed the projection of dataset to lcc. But whenever I tried to save the resampled file to .nc fomat I am frequently getting the errors. The code to project, resample and save the files are as follows:
#projection parameters
proj_dict = {
    'proj': 'lcc',
    'lon_0': -97.0,
    'lat_0': 40.0,
    'lat_1': 33.0,
    'lat_2': 45.0  
}

# area extent
area_extent = [-96.1433, 28.4111, -94.022, 30.3639]

# Resolution
width = 153
height = 162  

# area defination
my_area = create_area_def(
    'my_area',
    proj_dict,
    width=width,
    height=height,
    area_extent=area_extent,
    units='degrees'
)
local_scene= scn.resample(my_area)
local_scene.save_datasets(filename='resampled_output.nc', writer='cf')

InvalidVersion: Invalid version: '4.9.3-development'.Thanks in advance!
Ashish

David Hoese

unread,
Jul 16, 2024, 4:33:37 PM7/16/24
to pytroll
Hi Ashish,

That doesn't look like any error we're used to seeing in Satpy (or in any of my Python coding). Is there a larger traceback above this error message with context to why and where it is happening?

Dave

Asheesh Bhattarai

unread,
Jul 16, 2024, 9:34:19 PM7/16/24
to pyt...@googlegroups.com
This is the complete error message I have been receiving! 
---------------------------------------------------------------------------
InvalidVersion                            Traceback (most recent call last)
Cell In[21], line 1
----> 1 local_scene.save_datasets(filename='resampled1_output.nc', writer='cf')

File ~/.local/lib/python3.10/site-packages/satpy/scene.py:1293, in Scene.save_datasets(self, writer, filename, datasets, compute, **kwargs)
   1289         writer = self._get_writer_by_ext(os.path.splitext(filename)[1])
   1290 writer, save_kwargs = load_writer(writer,
   1291                                   filename=filename,
   1292                                   **kwargs)
-> 1293 return writer.save_datasets(dataarrays, compute=compute, **save_kwargs)

File ~/.local/lib/python3.10/site-packages/satpy/writers/cf_writer.py:267, in CFWriter.save_datasets(self, datasets, filename, groups, header_attrs, engine, epoch, flatten_attrs, exclude_attrs, include_lonlats, pretty, include_orig_name, numeric_name_prefix, **to_netcdf_kwargs)
    264 from satpy.cf.encoding import update_encoding
    266 logger.info("Saving datasets to NetCDF4/CF.")
--> 267 _check_backend_versions()
    269 # Define netCDF filename if not provided
    270 # - It infers the name from the first DataArray
    271 filename = filename or self.get_filename(**datasets[0].attrs)

File ~/.local/lib/python3.10/site-packages/satpy/writers/cf_writer.py:366, in _check_backend_versions()
    364 def _check_backend_versions():
    365     """Issue warning if backend versions do not match."""
--> 366     if not _backend_versions_match():
    367         warnings.warn(
    368             "Backend version mismatch. Compression might fail or be ignored "
    369             "silently. Recommended: All versions below or above "
    370             "netCDF4-1.6.0/libnetcdf-4.9.0/xarray-2022.12.0.",
    371             stacklevel=3
    372         )

File ~/.local/lib/python3.10/site-packages/satpy/writers/cf_writer.py:376, in _backend_versions_match()
    375 def _backend_versions_match():
--> 376     versions = _get_backend_versions()
    377     reference = {
    378         "netCDF4": Version("1.6.0"),
    379         "libnetcdf": Version("4.9.0"),
    380         "xarray": Version("2022.12.0")
    381     }
    382     is_newer = [
    383         versions[module] >= reference[module]
    384         for module in versions
    385     ]

File ~/.local/lib/python3.10/site-packages/satpy/writers/cf_writer.py:395, in _get_backend_versions()
    391 def _get_backend_versions():
    392     import netCDF4
    393     return {
    394         "netCDF4": Version(netCDF4.__version__),
--> 395         "libnetcdf": Version(netCDF4.__netcdf4libversion__),
    396         "xarray": Version(xr.__version__)
    397     }

File ~/.local/lib/python3.10/site-packages/packaging/version.py:202, in Version.__init__(self, version)
    200 match = self._regex.search(version)
    201 if not match:
--> 202     raise InvalidVersion(f"Invalid version: '{version}'")
    204 # Store the parsed out pieces of the version
    205 self._version = _Version(
    206     epoch=int(match.group("epoch")) if match.group("epoch") else 0,
    207     release=tuple(int(i) for i in match.group("release").split(".")),
   (...)
    213     local=_parse_local_version(match.group("local")),
    214 )

InvalidVersion: Invalid version: '4.9.3-development'

--
You received this message because you are subscribed to the Google Groups "pytroll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/90f512d3-9694-4642-bfdc-5a3de72ceea8n%40googlegroups.com.

David Hoese

unread,
Jul 16, 2024, 9:39:03 PM7/16/24
to pytroll
Thanks. This helps a lot. How did you install the NetCDF C library? The version of that library is being reported as "4.9.3-development" which is not a valid/typical/expected version number and the Satpy code that is checking this version number is failing to parse it. This could be handled better in Satpy probably, but we've also never seen NetCDF C report a version like this.

Dave

Asheesh Bhattarai

unread,
Jul 17, 2024, 3:34:31 AM7/17/24
to pyt...@googlegroups.com
I am working on the cluster computing and the libraries are installed normally while installing conda. I also tried on a local computer but the same error is generated. 

David Hoese

unread,
Jul 17, 2024, 12:24:54 PM7/17/24
to pytroll
Your traceback shows that Satpy is installed in "~/.local". So I'm guessing you installed Satpy in your home directory but are using the cluster's shared conda-based environment for everything else? Either way, I'm still confused where this NetCDF version of 4.9.3 is coming from. The version available from conda-forge is 4.9.2. The version from Anaconda's distribution is 4.8.1. The version available from ubuntu 22.04 when installed as a system package is 4.8.1. You could type out on the command line (not python):

nc-config --prefix
nc-config --version

To give us an idea of which version of the NetCDF C library is being used and from where.

Is there any chance you installed a development/unstable version of the NetCDF C library for some other work you're doing on the cluster?

Dave

Raspaud Martin

unread,
Jul 18, 2024, 3:50:31 AM7/18/24
to pytroll
Hi Ashish,

Thanks for reaching out!

I think we need a bit more information in order to help you, could you add the following to the beginning of your script to get more debug information?

from satpy.utils import debug_on
debug_on()

With that output we might be able to help you better.

Best regards,
Martin

________________________________________
From: pyt...@googlegroups.com <pyt...@googlegroups.com> on behalf of Asheesh Bhattarai <bhattarai...@gmail.com>
Sent: 16 July 2024 18:08:20
To: pytroll
Subject: [pytroll] Help!
--
You received this message because you are subscribed to the Google Groups "pytroll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com<mailto:pytroll+u...@googlegroups.com>.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/6cd59d68-a333-416d-894c-3b91d9bf2b70n%40googlegroups.com<https://groups.google.com/d/msgid/pytroll/6cd59d68-a333-416d-894c-3b91d9bf2b70n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages