def test_supplying_attributes(self):
        fid, single_tmp = tempfile.mkstemp(suffix='.nc')

        attrs = {
            'y': {
                '_CoordinateAxisType': 'Lat',
                '_FillValue': -9999.9,
                'missing_value': -9999.9,
            }
        }

        with OrthogonalMultidimensionalTimeseries(self.single) as s:
            df = s.to_dataframe()
            with OrthogonalMultidimensionalTimeseries.from_dataframe(
                    df, single_tmp, attributes=attrs) as result_ncd:
                assert 'station' in result_ncd.dimensions
                assert result_ncd.variables['y']._CoordinateAxisType == 'Lat'
                with self.assertRaises(AttributeError):
                    result_ncd.variables['y'].missing_value
                with self.assertRaises(AttributeError):
                    result_ncd.variables['y']._FillValue

        test_is_mine(OrthogonalMultidimensionalTimeseries,
                     single_tmp)  # Try to load it again
        os.close(fid)
        os.remove(single_tmp)
Example #2
0
    def test_load_strict(self):
        ncfile = os.path.join(os.path.dirname(__file__), 'dsg', 'profile', 'resources', 'om-single.nc')

        ncd = CFDataset.load(ncfile)
        assert omt.is_mine(ncd) is False
        with self.assertRaises(BaseException):
            omt.is_mine(ncd, strict=True)
        ncd.close()
Example #3
0
 def test_omp_dataframe(self):
     single_tmp = tempfile.mkstemp(suffix='.nc')[-1]
     with OrthogonalMultidimensionalTimeseries(self.single) as s:
         df = s.to_dataframe()
         nc = OrthogonalMultidimensionalTimeseries.from_dataframe(
             df, single_tmp)
         nc.close()
         logger.info(single_tmp)
 def test_timeseries_omp_dataframe(self):
     fid, single_tmp = tempfile.mkstemp(suffix='.nc')
     with OrthogonalMultidimensionalTimeseries(self.single) as s:
         df = s.to_dataframe()
         with OrthogonalMultidimensionalTimeseries.from_dataframe(
                 df, single_tmp) as result_ncd:
             assert 'station' in result_ncd.dimensions
     test_is_mine(OrthogonalMultidimensionalTimeseries,
                  single_tmp)  # Try to load it again
     os.close(fid)
     os.remove(single_tmp)
 def test_timeseries_omt_reduce_dims(self):
     fid, single_tmp = tempfile.mkstemp(suffix='.nc')
     with OrthogonalMultidimensionalTimeseries(self.single) as s:
         df = s.to_dataframe()
         with OrthogonalMultidimensionalTimeseries.from_dataframe(
                 df, single_tmp, reduce_dims=True) as result_ncd:
             assert 'station' not in result_ncd.dimensions
             assert np.ma.allclose(result_ncd.variables['pH'][:].flatten(),
                                   self.ph)
     test_is_mine(OrthogonalMultidimensionalTimeseries,
                  single_tmp)  # Try to load it again
     os.close(fid)
     os.remove(single_tmp)
 def test_timeseries_omt_dataframe_multi(self):
     fid, single_tmp = tempfile.mkstemp(suffix='.nc')
     with OrthogonalMultidimensionalTimeseries(self.multi) as s:
         df = s.to_dataframe()
         with OrthogonalMultidimensionalTimeseries.from_dataframe(
                 df, single_tmp) as result_ncd:
             assert 'station' in result_ncd.dimensions
             assert np.ma.allclose(
                 result_ncd.variables['temperature'][0, 0:7].flatten(),
                 [
                     18.61804, 13.2165, 39.30018, 17.00865, 24.95154,
                     35.99525, 24.33436
                 ],
             )
     test_is_mine(OrthogonalMultidimensionalTimeseries,
                  single_tmp)  # Try to load it again
     os.close(fid)
     os.remove(single_tmp)
 def test_timeseries_omt_no_z(self):
     fid, single_tmp = tempfile.mkstemp(suffix='.nc')
     with OrthogonalMultidimensionalTimeseries(self.single) as s:
         df = s.to_dataframe()
         axes = {'z': None}
         df.drop(columns=['z'], inplace=True)
         with OrthogonalMultidimensionalTimeseries.from_dataframe(
                 df,
                 single_tmp,
                 axes=axes,
         ) as result_ncd:
             assert 'station' in result_ncd.dimensions
             assert 'z' not in result_ncd.variables
             assert np.ma.allclose(result_ncd.variables['pH'][:].flatten(),
                                   self.ph)
     test_is_mine(OrthogonalMultidimensionalTimeseries,
                  single_tmp)  # Try to load it again
     os.close(fid)
     os.remove(single_tmp)
Example #8
0
 def test_load_url(self):
     ncd = CFDataset.load('http://geoport.whoi.edu/thredds/dodsC/usgs/data2/emontgomery/stellwagen/CF-1.6/ARGO_MERCHANT/1211-AA.cdf')
     assert omt.is_mine(ncd) is True
     ncd.close()
 def test_omp_load(self):
     OrthogonalMultidimensionalTimeseries(self.single).close()
     OrthogonalMultidimensionalTimeseries(self.multi).close()