Skip to content

Commit

Permalink
Merge pull request #139 from dstansby/tst-remote-data
Browse files Browse the repository at this point in the history
Mark remote data tests
  • Loading branch information
dstansby committed Feb 18, 2022
2 parents 829b403 + ef9ef95 commit 31f95d4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 30 deletions.
9 changes: 9 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ install_requires =
tests =
pytest >= 3.9
pytest-cov
pytest-remotedata
coveralls
flake8
mypy
Expand All @@ -54,6 +55,14 @@ docs =
[tool:pytest]
minversion = 3.9
addopts = -ra --cov=cdflib --cov-report=xml
filterwarnings =
error
# Astropy emits various warnings when dealing with dates/times, which are
# not an issue
ignore:ERFA function
# This is expected but safe when using binaries compiled with different
# numpy versions
ignore:numpy.ndarray size changed

[isort]
balanced_wrapping = True
Expand Down
64 changes: 34 additions & 30 deletions tests/test_xarray_reader_writer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import cdflib
import xarray as xr
import numpy as np
from cdflib.epochs import CDFepoch as cdfepoch
import urllib.request
import os
import urllib.request

import pytest
import xarray as xr

import cdflib

# To run these tests use `pytest --remote-data`

# These unit tests read in data to xarray, typically in the form of a CDF or netCDF file, and then spit it back out
# again into a CDF file. The created CDF files are then read back into xarray with the cdf_to_xarray function.
Expand All @@ -15,6 +18,7 @@
# The primary motivation for doing so was to read the data into xarray using different methods (cdf_to_xarray vs load_dataset)


@pytest.mark.remote_data
def test_mms_fpi():
fname = 'mms1_fpi_brst_l2_des-moms_20151016130334_v3.3.0.cdf'
url = ("https://lasp.colorado.edu/maven/sdc/public/data/sdc/web/cdflib_testing/mms1_fpi_brst_l2_des-moms_20151016130334_v3.3.0.cdf")
Expand Down Expand Up @@ -47,6 +51,7 @@ def test_mms_fpi():
os.remove('mms1_fpi_brst_l2_des-moms_20151016130334_v3.3.0.nc')


@pytest.mark.remote_data
def test_mms_epd():
fname = 'mms2_epd-eis_srvy_l2_extof_20160809_v3.0.4.cdf'
url = (
Expand Down Expand Up @@ -75,7 +80,7 @@ def test_mms_epd():
os.remove('mms2_epd-eis_srvy_l2_extof_20160809_v3.0.4-created-from-netcdf-input.cdf')
os.remove('mms2_epd-eis_srvy_l2_extof_20160809_v3.0.4.nc')


@pytest.mark.remote_data
def test_mms_fgm():

fname = 'mms2_fgm_srvy_l2_20160809_v4.47.0.cdf'
Expand Down Expand Up @@ -105,7 +110,7 @@ def test_mms_fgm():
os.remove('mms2_fgm_srvy_l2_20160809_v4.47.0-created-from-netcdf-input.cdf')
os.remove('mms2_fgm_srvy_l2_20160809_v4.47.0.nc')


@pytest.mark.remote_data
def test_MGITM_model():

fname = 'MGITM_LS180_F130_150615.nc'
Expand All @@ -128,7 +133,7 @@ def test_MGITM_model():
os.remove('MGITM_LS180_F130_150615-created-from-netcdf-input.cdf')
os.remove('MGITM_LS180_F130_150615.nc')


@pytest.mark.remote_data
def test_goes_mag():

fname = 'dn_magn-l2-hires_g17_d20211219_v1-0-1.nc'
Expand All @@ -149,7 +154,7 @@ def test_goes_mag():
os.remove('dn_magn-l2-hires_g17_d20211219_v1-0-1-created-from-netcdf-input.cdf')
os.remove('dn_magn-l2-hires_g17_d20211219_v1-0-1.nc')


@pytest.mark.remote_data
def test_saber():

fname = 'SABER_L2B_2021020_103692_02.07.nc'
Expand All @@ -171,7 +176,7 @@ def test_saber():
os.remove('SABER_L2B_2021020_103692_02.07-created-from-netcdf-input.cdf')
os.remove('SABER_L2B_2021020_103692_02.07.nc')


@pytest.mark.remote_data
def test_euv():

fname = 'mvn_euv_l3_minute_20201130_v14_r02.cdf'
Expand All @@ -188,7 +193,7 @@ def test_euv():
os.remove('mvn_euv_l3_minute_20201130_v14_r02-created-from-cdf-input.cdf')
os.remove('mvn_euv_l3_minute_20201130_v14_r02.cdf')


@pytest.mark.remote_data
def test_lpw_lpiv():

fname = 'mvn_lpw_l2_lpiv_20180717_v02_r02.cdf'
Expand Down Expand Up @@ -218,7 +223,7 @@ def test_lpw_lpiv():
os.remove('mvn_lpw_l2_lpiv_20180717_v02_r02-created-from-netcdf-input.cdf')
os.remove('mvn_lpw_l2_lpiv_20180717_v02_r02.nc')


@pytest.mark.remote_data
def test_lpw_lpnt():

fname = 'mvn_lpw_l2_lpnt_20180717_v03_r01.cdf'
Expand Down Expand Up @@ -248,7 +253,7 @@ def test_lpw_lpnt():
os.remove('mvn_lpw_l2_lpnt_20180717_v03_r01-created-from-netcdf-input.cdf')
os.remove('mvn_lpw_l2_lpnt_20180717_v03_r01.nc')


@pytest.mark.remote_data
def test_lpw_mrgscpot():

fname = 'mvn_lpw_l2_mrgscpot_20180717_v02_r01.cdf'
Expand Down Expand Up @@ -278,7 +283,7 @@ def test_lpw_mrgscpot():
os.remove('mvn_lpw_l2_mrgscpot_20180717_v02_r01-created-from-netcdf-input.cdf')
os.remove('mvn_lpw_l2_mrgscpot_20180717_v02_r01.nc')


@pytest.mark.remote_data
def test_sep_anc():

fname = 'mvn_sep_l2_anc_20210501_v06_r00.cdf'
Expand All @@ -295,7 +300,7 @@ def test_sep_anc():
os.remove('mvn_sep_l2_anc_20210501_v06_r00-created-from-cdf-input.cdf')
os.remove('mvn_sep_l2_anc_20210501_v06_r00.cdf')


@pytest.mark.remote_data
def test_sep_svy():

fname = 'mvn_sep_l2_s2-raw-svy-full_20191231_v04_r05.cdf'
Expand Down Expand Up @@ -334,7 +339,7 @@ def test_sta():
os.remove('mvn_sta_l2_d1-32e4d16a8m_20201130_v02_r04.cdf')
'''


@pytest.mark.remote_data
def test_swe_arc3d():

fname = 'mvn_swe_l2_arc3d_20180717_v04_r02.cdf'
Expand Down Expand Up @@ -364,7 +369,7 @@ def test_swe_arc3d():
os.remove('mvn_swe_l2_arc3d_20180717_v04_r02-created-from-netcdf-input.cdf')
os.remove('mvn_swe_l2_arc3d_20180717_v04_r02.nc')


@pytest.mark.remote_data
def test_swe_svyspec():

fname = 'mvn_swe_l2_svyspec_20180718_v04_r04.cdf'
Expand Down Expand Up @@ -394,7 +399,7 @@ def test_swe_svyspec():
os.remove('mvn_swe_l2_svyspec_20180718_v04_r04-created-from-netcdf-input.cdf')
os.remove('mvn_swe_l2_svyspec_20180718_v04_r04.nc')


@pytest.mark.remote_data
def test_swi_finearc3d():

fname = 'mvn_swi_l2_finearc3d_20180720_v01_r01.cdf'
Expand Down Expand Up @@ -424,7 +429,7 @@ def test_swi_finearc3d():
os.remove('mvn_swi_l2_finearc3d_20180720_v01_r01-created-from-netcdf-input.cdf')
os.remove('mvn_swi_l2_finearc3d_20180720_v01_r01.nc')


@pytest.mark.remote_data
def test_swi_onboardsvyspec():

fname = 'mvn_swi_l2_onboardsvyspec_20180720_v01_r01.cdf'
Expand Down Expand Up @@ -454,7 +459,7 @@ def test_swi_onboardsvyspec():
os.remove('mvn_swi_l2_onboardsvyspec_20180720_v01_r01-created-from-netcdf-input.cdf')
os.remove('mvn_swi_l2_onboardsvyspec_20180720_v01_r01.nc')


@pytest.mark.remote_data
def test_omni():

fname = 'omni_hro2_1min_20151001_v01.cdf'
Expand Down Expand Up @@ -484,7 +489,7 @@ def test_omni():
os.remove('omni_hro2_1min_20151001_v01-created-from-netcdf-input.cdf')
os.remove('omni_hro2_1min_20151001_v01.nc')


@pytest.mark.remote_data
def test_raids():

fname = 'raids_nirs_20100823_v1.1.nc'
Expand All @@ -502,7 +507,7 @@ def test_raids():


'''
# TOO MUCH MEMORY
# TOO MUCH MEMORY
def test_rbsp():
Expand All @@ -522,7 +527,7 @@ def test_rbsp():
os.remove('rbsp-a_magnetometer_1sec-gsm_emfisis-l3_20190122_v1.6.2.cdf')
'''


@pytest.mark.remote_data
def test_see_l3():

fname = 'see__L3_2021009_012_01.ncdf'
Expand All @@ -537,7 +542,7 @@ def test_see_l3():
os.remove('see__L3_2021009_012_01.ncdfhello2.cdf')
os.remove('see__L3_2021009_012_01.ncdf')


@pytest.mark.remote_data
def test_see_l2a():

fname = 'see__xps_L2A_2021006_012_02.ncdf'
Expand All @@ -552,7 +557,7 @@ def test_see_l2a():
os.remove('see__xps_L2A_2021006_012_02.ncdfhello2.cdf')
os.remove('see__xps_L2A_2021006_012_02.ncdf')


@pytest.mark.remote_data
def test_something():

fname = 'sgpsondewnpnC1.nc'
Expand All @@ -566,8 +571,8 @@ def test_something():
d = cdflib.cdf_to_xarray('sgpsondewnpnC1-created-from-netcdf-input.cdf', to_unixtime=True, fillval_to_nan=True)
os.remove('sgpsondewnpnC1-created-from-netcdf-input.cdf')
os.remove('sgpsondewnpnC1.nc')


@pytest.mark.remote_data
def test_themis_sst():

fname = 'thc_l2_sst_20210709_v01.cdf'
Expand Down Expand Up @@ -597,7 +602,7 @@ def test_themis_sst():
os.remove('thc_l2_sst_20210709_v01-created-from-netcdf-input.cdf')
os.remove('thc_l2_sst_20210709_v01.nc')


@pytest.mark.remote_data
def test_themis_mag():

fname = 'thg_l2_mag_amd_20070323_v01.cdf'
Expand Down Expand Up @@ -627,7 +632,7 @@ def test_themis_mag():
os.remove('thg_l2_mag_amd_20070323_v01-created-from-netcdf-input.cdf')
os.remove('thg_l2_mag_amd_20070323_v01.nc')


@pytest.mark.remote_data
def test_wi_elsp():

fname = 'wi_elsp_3dp_20210115_v01.cdf'
Expand Down Expand Up @@ -657,7 +662,7 @@ def test_wi_elsp():
os.remove('wi_elsp_3dp_20210115_v01-created-from-netcdf-input.cdf')
os.remove('wi_elsp_3dp_20210115_v01.nc')


@pytest.mark.remote_data
def test_wi_k0():

fname = 'wi_k0_spha_20210121_v01.cdf'
Expand Down Expand Up @@ -687,7 +692,6 @@ def test_wi_k0():
os.remove('wi_k0_spha_20210121_v01-created-from-netcdf-input.cdf')
os.remove('wi_k0_spha_20210121_v01.nc')


def test_build_from_scratch():
var_data = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
var_dims = ['epoch', 'direction']
Expand Down

0 comments on commit 31f95d4

Please sign in to comment.