Пример #1
0
def test_get_data_as_dataframes():
    for test_pixel_kwargs in test_pixels:
        pixel_data = daymet.get_daymet_singlepixel(**test_pixel_kwargs)
        assert pixel_data.shape == (len(test_pixel_kwargs['years'])*365, len(test_pixel_kwargs['variables'])+2)
        assert pixel_data.iloc[0].year == test_pixel_kwargs['years'][0]
        assert pixel_data.iloc[-1].year == test_pixel_kwargs['years'][-1]
        for var in test_pixel_kwargs['variables']:
            assert var in pixel_data.keys()
Пример #2
0
def test_get_data_as_dicts():
    for test_pixel_kwargs in test_pixels:
        test_pixel_kwargs['as_dataframe'] = False
        pixel_data = daymet.get_daymet_singlepixel(**test_pixel_kwargs)
        assert len(pixel_data.keys()) ==  len(test_pixel_kwargs['variables'])
        assert "{}-01-01".format(test_pixel_kwargs['years'][0]) in pixel_data[test_pixel_kwargs['variables'][0]].keys()
        assert "{}-12-30".format(test_pixel_kwargs['years'][-1]) in pixel_data[test_pixel_kwargs['variables'][0]].keys()
        for var in test_pixel_kwargs['variables']:
            assert var in pixel_data.keys()
Пример #3
0
def test_get_data_as_dataframes():
    for test_pixel_kwargs in test_pixels:
        pixel_data = daymet.get_daymet_singlepixel(**test_pixel_kwargs)
        assert pixel_data.shape == (len(test_pixel_kwargs['years']) * 365,
                                    len(test_pixel_kwargs['variables']) + 2)
        assert pixel_data.iloc[0].year == test_pixel_kwargs['years'][0]
        assert pixel_data.iloc[-1].year == test_pixel_kwargs['years'][-1]
        for var in test_pixel_kwargs['variables']:
            assert var in pixel_data.keys()
Пример #4
0
def test_get_data_as_dicts():
    for test_pixel_kwargs in test_pixels:
        test_pixel_kwargs['as_dataframe'] = False
        pixel_data = daymet.get_daymet_singlepixel(**test_pixel_kwargs)
        assert len(pixel_data.keys()) == len(test_pixel_kwargs['variables'])
        assert "{}-01-01".format(test_pixel_kwargs['years'][0]) in pixel_data[
            test_pixel_kwargs['variables'][0]].keys()
        assert "{}-12-30".format(test_pixel_kwargs['years'][-1]) in pixel_data[
            test_pixel_kwargs['variables'][0]].keys()
        for var in test_pixel_kwargs['variables']:
            assert var in pixel_data.keys()
# 
# Daymet is a a daily gridded weather dataset distributed through the ORNL DAAC https://daymet.ornl.gov/
# 
# As part of their tools for obtaining data they have created a webservice that allows one to download a timeseries of temperature and precipitation for any location in the US.
# 

# In[1]:

from ulmo.nasa import daymet


# In[2]:

ornl_lat, ornl_long = 35.9313167, -84.3104124
df = daymet.get_daymet_singlepixel(longitude=ornl_long, latitude=ornl_lat, 
                                   years=[2012,2013])


# ### Which gives us a dataframe with daily weather data for the Oak Ridge National Lab

# In[3]:

df.head()


# ### Which we can visualize using matplotlib and seaborn

# In[4]:

import pandas as pd
import seaborn as sns
#
# Daymet is a a daily gridded weather dataset distributed through the ORNL DAAC https://daymet.ornl.gov/
#
# As part of their tools for obtaining data they have created a webservice that allows one to download a timeseries of temperature and precipitation for any location in the US.
#

# In[1]:

from ulmo.nasa import daymet

# In[2]:

ornl_lat, ornl_long = 35.9313167, -84.3104124
df = daymet.get_daymet_singlepixel(longitude=ornl_long,
                                   latitude=ornl_lat,
                                   years=[2012, 2013])

# ### Which gives us a dataframe with daily weather data for the Oak Ridge National Lab

# In[3]:

df.head()

# ### Which we can visualize using matplotlib and seaborn

# In[4]:

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt