oceanmodeling / adcircpy

Python library for managing input and output files for the ADCIRC model
https://adcircpy.readthedocs.io/en/latest/
GNU General Public License v3.0
34 stars 25 forks source link

OSError when downloading hamtide on Windows #48

Closed ghost closed 3 years ago

ghost commented 3 years ago

when running tests in CoupledModelDriver on my local (Windows) machine, the following error is raised:

OSError: [Errno -37] NetCDF: Write to read only: b'https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/m2.hamtide11a.nc'

here is the full pytest output:

FAILED           [ 33%][2021-03-02 10:20:50,534] adcirc          INFO    : writing config to "output\local_shinnecock_ike\runs\test_case_1"
[2021-03-02 10:19:49,922] adcirc          WARNING : mesh values (nodal attributes) not found at "input\shinnecock_ike\mesh\fort.13"
[2021-03-02 10:19:53,153] configuration WARNING : could not create symbolic link: [WinError 1314] A required privilege is not held by the client: 'output\\local_shinnecock_ike\\model_configure' -> 'output\\local_shinnecock_ike\\atm_namelist.rc'
[2021-03-02 10:19:56,326] configuration WARNING : could not create symbolic link: [WinError 1314] A required privilege is not held by the client: 'output\\local_shinnecock_ike\\model_configure' -> 'output\\local_shinnecock_ike\\atm_namelist.rc'
Cookie file cannot be read and written: (null)

tests\test_configurations.py:30 (test_local_shinnecock_ike)
def test_local_shinnecock_ike():
        platform = 'local'
        mesh = 'shinnecock'
        storm = 'ike'

        input_directory = Path('.') / 'input' / f'{mesh}_{storm}'
        mesh_directory = download_mesh(mesh, storm, input_directory)
        forcings_directory = input_directory / 'forcings'

        output_directory = Path('.') / 'output' / f'{platform}_{mesh}_{storm}'
        reference_directory = Path('.') / 'reference' / f'{platform}_{mesh}_{storm}'

        runs = {f'test_case_1': (None, None)}

        nems = ModelingSystem(
            start_time=datetime(2008, 8, 23),
            end_time=datetime(2008, 8, 23) + timedelta(days=14.5),
            interval=timedelta(hours=1),
            atm=AtmosphericMeshEntry(forcings_directory / 'wind_atm_fin_ch_time_vec.nc'),
            wav=WaveMeshEntry(forcings_directory / 'ww3.Constant.20151214_sxy_ike_date.nc'),
            ocn=ADCIRCEntry(11),
        )

        nems.connect('ATM', 'OCN')
        nems.connect('WAV', 'OCN')
        nems.sequence = [
            'ATM -> OCN',
            'WAV -> OCN',
            'ATM',
            'WAV',
            'OCN',
        ]

        tidal_forcing = Tides()
        tidal_forcing.use_all()
        wind_forcing = AtmosphericMeshForcing(nws=17, interval_seconds=3600)
        wave_forcing = WaveWatch3DataForcing(nrs=5, interval_seconds=3600)

>       write_adcirc_configurations(
            nems,
            runs,
            mesh_directory,
            output_directory,
            email_address='example@email.gov',
            platform=Platform.LOCAL,
            spinup=timedelta(days=12.5),
            forcings=[tidal_forcing, wind_forcing, wave_forcing],
            overwrite=True,
        )

C:\Repositories\CoupledModelDriver\tests\test_configurations.py:69: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Repositories\CoupledModelDriver\coupledmodeldriver\adcirc.py:298: in write_adcirc_configurations
    driver.write(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\driver.py:411: in write
    super().write('hotstart', output_directory / hotstart,
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\fort15.py:312: in write
    f.write(self.fort15(runtype))
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\fort15.py:91: in fort15
    f.append(self.get_tidal_forcing())
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\fort15.py:345: in get_tidal_forcing
    amp, phase = self.tidal_forcing.tidal_database(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:44: in __call__
    amp = self.get_amplitude(constituent, vertices)
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:51: in get_amplitude
    return self._get_interpolation(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:97: in _get_interpolation
    zi = self._get_resource(
C:\Environments\CoupledModelDriver\lib\site-packages\adcircpy\forcing\tides\hamtide.py:84: in _get_resource
    return Dataset(base_url + fname)
src\netCDF4\_netCDF4.pyx:2330: in netCDF4._netCDF4.Dataset.__init__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   OSError: [Errno -37] NetCDF: Write to read only: b'https://icdc.cen.uni-hamburg.de/thredds/dodsC/ftpthredds/hamtide/m2.hamtide11a.nc'

src\netCDF4\_netCDF4.pyx:1948: OSError
ghost commented 3 years ago

stack trace:

CoupledModelDriver

https://github.com/noaa-ocs-modeling/CoupledModelDriver/blob/967176800a0ae923e0a51e8e9fdca755ea7558e1/tests/test_configurations.py#L31-L83

https://github.com/noaa-ocs-modeling/CoupledModelDriver/blob/967176800a0ae923e0a51e8e9fdca755ea7558e1/coupledmodeldriver/adcirc.py#L281-L304

ADCIRCPy

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/driver.py#L411-L412

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/fort15.py#L305-L312

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/fort15.py#L91

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/fort15.py#L345-L346

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/forcing/tides/hamtide.py#L43-L46

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/forcing/tides/hamtide.py#L48-L52

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/forcing/tides/hamtide.py#L86-L98

https://github.com/JaimeCalzadaNOAA/adcircpy/blob/6f6a34d84b42ba5628a450e7d6df4f6cae38a051/adcircpy/forcing/tides/hamtide.py#L76-L84

ghost commented 3 years ago

Is this happening if you run it in your local machine? I suspect it's trying to write netCDF4 metadata to a read-only file system.

ghost commented 3 years ago

Is this happening if you run it in your local machine? I suspect it's trying to write netCDF4 metadata to a read-only file system.

yes, this is from my local machine. Where should it be writing to?

ghost commented 3 years ago

Is this a Windows machine?

ghost commented 3 years ago

Is this a Windows machine?

yes, I will try running it on WSL to see if the result is different

ghost commented 3 years ago

It appears to have worked fine on WSL. I will chalk this up to a Windows bug.

jreniel commented 3 years ago

It might be the NetCDF4 version. Maybe try upgrading it? If it works fine on WSL I'm good with that.

On Tue, Mar 2, 2021 at 12:22 PM Zachary Burnett notifications@github.com wrote:

It appears to have worked fine on WSL. I will chalk this up to a Windows bug.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JaimeCalzadaNOAA/adcircpy/issues/48#issuecomment-789073363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXYQTW4YITUD6PGGLE7PKTTBUNGHANCNFSM4YPGSHKA .

-- Jaime R. Calzada-Marrero, M.Sc.

ghost commented 3 years ago

It might be the NetCDF4 version. Maybe try upgrading it? If it works fine on WSL I'm good with that.

it seems to break the github workflow tests running windows in the matrix, which should always be a clean copy (except for the package cache)

I will just remove windows from the testing workflow for now until it can be resolved (if it can)