-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from CDJellen/user/cjellen/netcdf-support
Add firsdt-class NetCDF4 file support through NDBC DODS/THREDDS
- Loading branch information
Showing
173 changed files
with
2,420 additions
and
870 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
from datetime import datetime, timedelta | ||
from typing import Any | ||
|
||
import netCDF4 as nc | ||
|
||
from ndbc_api.api.handlers._base import BaseHandler | ||
from ndbc_api.api.parsers.opendap.adcp import AdcpParser | ||
from ndbc_api.api.parsers.opendap.cwind import CwindParser | ||
from ndbc_api.api.parsers.opendap.ocean import OceanParser | ||
from ndbc_api.api.parsers.opendap.pwind import PwindParser | ||
from ndbc_api.api.parsers.opendap.stdmet import StdmetParser | ||
from ndbc_api.api.parsers.opendap.swden import SwdenParser | ||
from ndbc_api.api.parsers.opendap.wlevel import WlevelParser | ||
from ndbc_api.api.requests.opendap.adcp import AdcpRequest | ||
from ndbc_api.api.requests.opendap.cwind import CwindRequest | ||
from ndbc_api.api.requests.opendap.ocean import OceanRequest | ||
from ndbc_api.api.requests.opendap.pwind import PwindRequest | ||
from ndbc_api.api.requests.opendap.stdmet import StdmetRequest | ||
from ndbc_api.api.requests.opendap.swden import SwdenRequest | ||
from ndbc_api.api.requests.opendap.wlevel import WlevelRequest | ||
from ndbc_api.exceptions import RequestException, ResponseException | ||
|
||
|
||
class OpenDapDataHandler(BaseHandler): | ||
|
||
@classmethod | ||
def adcp( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""adcp""" | ||
try: | ||
reqs = AdcpRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return AdcpParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) | ||
|
||
@classmethod | ||
def cwind( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""cwind""" | ||
try: | ||
reqs = CwindRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return CwindParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) | ||
|
||
@classmethod | ||
def ocean( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""ocean""" | ||
try: | ||
reqs = OceanRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return OceanParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) | ||
|
||
@classmethod | ||
def pwind( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""pwind""" | ||
try: | ||
reqs = PwindRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return PwindParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) | ||
|
||
@classmethod | ||
def stdmet( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""stdmet""" | ||
try: | ||
reqs = StdmetRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return StdmetParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) | ||
|
||
@classmethod | ||
def swden( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""swden""" | ||
try: | ||
reqs = SwdenRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return SwdenParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) | ||
|
||
@classmethod | ||
def wlevel( | ||
cls, | ||
handler: Any, | ||
station_id: str, | ||
start_time: datetime = datetime.now() - timedelta(days=30), | ||
end_time: datetime = datetime.now(), | ||
use_timestamp: bool = True, | ||
) -> 'nc.Dataset': | ||
"""wlevel""" | ||
try: | ||
reqs = WlevelRequest.build_request(station_id=station_id, | ||
start_time=start_time, | ||
end_time=end_time) | ||
except Exception as e: | ||
raise RequestException('Failed to build request.') from e | ||
try: | ||
resps = handler.handle_requests(station_id=station_id, reqs=reqs) | ||
except Exception as e: | ||
raise ResponseException('Failed to execute requests.') from e | ||
return WlevelParser.nc_from_responses(responses=resps, | ||
use_timestamp=use_timestamp) |
File renamed without changes.
1 change: 0 additions & 1 deletion
1
ndbc_api/api/parsers/_base.py → ndbc_api/api/parsers/http/_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from datetime import datetime | ||
from io import StringIO | ||
from typing import List, Tuple | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
ndbc_api/api/parsers/_xml.py → ndbc_api/api/parsers/http/_xml.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ndbc_api/api/parsers/station_realtime.py → ..._api/api/parsers/http/station_realtime.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.