Commit 67d15839 authored by PIOLLE's avatar PIOLLE
Browse files

Initial commit

parents
==============================================
Cerbere extensions for WHALES retracker format
==============================================
Classes derived from Cerbere base class :class:`~cerbere.dataset.dataset.Dataset`
to read output files of TUM/WHALES altimeter retracker.
Tested products
===============
* WHALES output from ESA ENVISAT version 3 SGDR products (:class:`WHALESNCDataset`, :class:`Trajectory`)
* WHALES output from ESA CryoSat2 version D LRM L1B products (:class:`WHALESNCDataset`, :class:`Trajectory`)
* WHALES output from ESA SARAL SGDR version T products (:class:`WHALESNCDataset`, :class:`Trajectory`)
Installation
============
Requires ``cerbere>=2.0.0``
Test data
=========
Sample products for each class can be found at:
ftp://ftp.ifremer.fr/ifremer/cersat/projects/cerbere/test_data/
They are used by the unitary tests in ``tests`` directory.
Usage example
=============
.. code-block:: python
import cerbere
# open file
dst = cerbere.open_dataset(
'CS_LTA__SIR_LRM_1B_20100719T070328_20100719T070439_D001.nc',
'WHALESNCDataset'
)
print(dst.get_times())
print(dst.get_lon())
print(dst.fieldnames)
print(dst.get_values('swh_WHALES_20hz'))
# -*- coding: utf-8 -*-
"""
:mod:`~cerbere.dataset` class to read WHALES netCDF files
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import datetime
import logging
import xarray as xr
from cerbere.dataset.dataset import Dataset
DEFAULT_TIME_UNITS = "seconds since 2000-01-01 00:00:00.0"
class WHALESNCDataset(Dataset):
"""WHALES Retracker NetCDF Dataset
Args:
time_units: time units (not provided in WHALES output files)
"""
def __init__(self, *args, time_units: str = DEFAULT_TIME_UNITS, **kwargs):
self.time_units = time_units
return super(WHALESNCDataset, self).__init__(
*args,
field_matching={
'time_20hz': 'time', 'lat_20hz': 'lat', 'lon_20hz': 'lon'},
**kwargs)
def _transform(self):
self._std_dataset = self._std_dataset.squeeze('records')
self._std_dataset['time'].attrs['units'] = self.time_units
self._std_dataset = xr.decode_cf(self._std_dataset)
return super(WHALESNCDataset, self)._transform()
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
long_desc = '''
This package contains the Cerbere extension for TUM/WHALES retracker output format.
'''
requires = [
# 'cerbere>=2.0.0',
]
setup(
name='cerberecontrib-whales',
version='1.0',
url='',
license='GPLv3',
authors='Jean-François Piollé',
author_email='jfpiolle@ifremer.fr',
description='Cerbere extension for TUM/WHALES retracker output format',
long_description=long_desc,
zip_safe=False,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
entry_points={
'cerbere.plugins': [
'WHALESNCDataset = cerberecontrib_whales.dataset.whalesncdataset:WHALESNCDataset',
]
},
platforms='any',
packages=find_packages(),
include_package_data=True,
install_requires=requires,
)
"""
Test class for cerbere CRYOSAT2vDWHALESNCDataset class, WHALES output from
ESA CryoSat-2 version D LRM L1B products.
:copyright: Copyright 2020 Ifremer / Cersat.
:license: Released under GPL v3 license, see :ref:`license`.
.. sectionauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
.. codeauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
"""
import unittest
from tests.checker import Checker
class CRYOSAT2vDWHALESNCDatasetChecker(Checker, unittest.TestCase):
"""Test class for WHALESNCDataset files"""
def __init__(self, methodName="runTest"):
super(CRYOSAT2vDWHALESNCDatasetChecker, self).__init__(methodName)
@classmethod
def dataset(cls):
"""Return the mapper class name"""
return 'WHALESNCDataset'
@classmethod
def feature(cls):
"""Return the related feature class name"""
return 'Trajectory'
@classmethod
def test_file(cls):
"""Return the name of the test file for this test"""
return "CS_LTA__SIR_LRM_1B_20100719T070328_20100719T070439_D001.nc"
@classmethod
def download_url(cls):
"""Return the URL of the data test repository where to get the test
files
"""
return "ftp://ftp.ifremer.fr/ifremer/cersat/projects/cerbere/test_data/"
"""
Test class for cerbere WHALESNCDataset class, WHALES output from
ESA ENVISAT v3 SGDR products.
:copyright: Copyright 2020 Ifremer / Cersat.
:license: Released under GPL v3 license, see :ref:`license`.
.. sectionauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
.. codeauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
"""
import unittest
from tests.checker import Checker
class ENVISATv3WHALESNCDatasetChecker(Checker, unittest.TestCase):
"""Test class for WHALESNCDataset files"""
def __init__(self, methodName="runTest"):
super(ENVISATv3WHALESNCDatasetChecker, self).__init__(methodName)
@classmethod
def dataset(cls):
"""Return the mapper class name"""
return 'WHALESNCDataset'
@classmethod
def feature(cls):
"""Return the related feature class name"""
return 'Trajectory'
@classmethod
def test_file(cls):
"""Return the name of the test file for this test"""
return "ENV_RA_2_MWS____20100101T000047_20100101T005104_20170905T025157_3017_085_0691____PAC_R_NT_003.nc"
@classmethod
def download_url(cls):
"""Return the URL of the data test repository where to get the test
files
"""
return "ftp://ftp.ifremer.fr/ifremer/cersat/projects/cerbere/test_data/"
"""
Test class for cerbere WHALESNCDataset class, WHALES output from
AVISO SARAL Version T SGDR products.
:copyright: Copyright 2020 Ifremer / Cersat.
:license: Released under GPL v3 license, see :ref:`license`.
.. sectionauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
.. codeauthor:: Jeff Piolle <jfpiolle@ifremer.fr>
"""
import unittest
from tests.checker import Checker
class SARALvTWHALESNCDatasetChecker(Checker, unittest.TestCase):
"""Test class for WHALESNCDataset files"""
def __init__(self, methodName="runTest"):
super(SARALvTWHALESNCDatasetChecker, self).__init__(methodName)
@classmethod
def dataset(cls):
"""Return the mapper class name"""
return 'WHALESNCDataset'
@classmethod
def feature(cls):
"""Return the related feature class name"""
return 'Trajectory'
@classmethod
def test_file(cls):
"""Return the name of the test file for this test"""
return "SRL_GPS_2PTP126_0015_20190101_042030_20190101_051048.CNES.nc.nc"
@classmethod
def download_url(cls):
"""Return the URL of the data test repository where to get the test
files
"""
return "ftp://ftp.ifremer.fr/ifremer/cersat/projects/cerbere/test_data/"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment