In [ ]:
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

In [ ]:
import sys
print(sys.version)

In [ ]:
##################
# Imports        #
##################
# import the podaac package
import podaac.podaac as podaac
# import the podaac_utils package
import podaac.podaac_utils as utils
# import the mcc package
import podaac.mcc as mcc

#######################
# Class instantiation #
#######################
# then create an instance of the Podaac class
p = podaac.Podaac()
# then create an instance of the PodaacUtils class
u = utils.PodaacUtils()
# then create an instance of the MCC class
m = mcc.MCC()

In [ ]:
###########################################
# Lets look at some convenience functions #
###########################################
print(u.list_all_available_extract_granule_dataset_ids())

In [ ]:
print(u.list_all_available_extract_granule_dataset_short_names())

In [ ]:
print(u.list_all_available_granule_search_dataset_ids())

In [ ]:
print(u.list_all_available_granule_search_dataset_short_names())

In [ ]:
print(u.list_available_granule_search_level2_dataset_ids())

In [ ]:
print(u.list_available_granule_search_level2_dataset_short_names())

In [ ]:
# Now lets take a look at using the results from above to interact with the PO.DAAC Webservices

########################
# PO.DAAC Web Services #
########################

# First lets retrieve dataset metadata
print(p.dataset_metadata(dataset_id='PODAAC-GHMG2-2PO01'))

In [ ]:
# Lets try searching for datasets
print(p.dataset_search(keyword='modis'))

In [ ]:
# Now retrieve dataset variables
print(p.dataset_variables(dataset_id='PODAAC-GHMDA-2PJ02'))

In [ ]:
# Now extracting an individual granule
print(p.extract_l4_granule(dataset_id='PODAAC-AQR50-3YVAS'))

In [ ]:
# Now retrieving granule metadata
print(p.granule_metadata(dataset_id='PODAAC-GHMG2-2PO01'), granule_name='20120912-MSG02-OSDPD-L2P-MSG02_0200Z-v01.nc')

In [ ]:
from IPython.display import Image
from IPython.core.display import HTML 
result = p.granule_preview(dataset_id='PODAAC-ASOP2-25X01')

In [ ]:
# Additionally, we can search metadata for list of granules archived within the last 24 hours in Datacasting format.
print(p.last24hours_datacasting_granule_md(dataset_id='PODAAC-AQR50-3YVAS'))

In [ ]:
# Now Searching for Granules
print(p.granule_search(dataset_id='PODAAC-ASOP2-25X01',bbox='0,0,180,90',start_time='2013-01-01T01:30:00Z',end_time='2014-01-01T00:00:00Z',start_index='1', pretty='True'))

In [ ]:
######################################################
# Working with Metadata Compliance Webservices (mcc) #
######################################################

# Compliance Check a Local File
print(m.check_local_file(acdd_version='1.3', gds2_parameters='L4', file_upload='../podaac/tests/ascat_20130719_230600_metopa_35024_eps_o_250_2200_ovw.l2_subsetted_.nc', response='json'))

In [ ]:
# Compliance Check a Remote File
print(m.check_remote_file(checkers='CF', url_upload='http://test.opendap.org/opendap/data/ncml/agg/dated/CG2006158_120000h_usfc.nc', response='json'))

In [ ]:
# Thank you for trying out podaacpy
# That concludes the quick start. Hopefully this has been helpful in providing an overview 
# of the main podaacpy features. If you have any issues with this document then please register 
# them at the issue tracker - https://github.com/nasa/podaacpy/issues
# Please use labels to classify your issue.

# Thanks, 
# Lewis John McGibbney