FAQ
- How to setup Python for using NAAD direct access (DAP)
- How to use direct access (DAP) in Python: Examples
How to setup Python for using NAAD direct access (DAP)
You need to install Pydap
, requests
and lxml
in your Python environment (if not installed already):
# pip install Pydap requests lxml
How to use direct access (DAP) in Python: Example
To get direct access to the NAAD, you need to connect to the server first. It can be accomplished by using setup_session
from the pydap
library. To get the file handler, use setup_session
from the same library. So the final code will look like:
from pydap.client import open_url from pydap.cas.get_cookies import setup_session # connect to the NAAD database session = setup_session("https://naad.ocean.ru/accounts/login/", username="USER_NAME", password="USER_PASSWORD" ) # get the file handler dataset = open_url('https://naad.ocean.ru/dapserver/LoRes/Invariants/NAAD77km_isor.nc', session=session) # read the variable var = dataset['isor'] # print the array sizes print(var.shape)
Here we accessed the NAAD database, read the static variable isor
from the NAAD LoRes dataset and printed the shape of the array.