In [1]:
import os
import pandas as pd
import matplotlib.pyplot as plt
import xarray as xr
%matplotlib inline

In [26]:
root_path = "/home/jovyan/work/datacube/esdc-8d-0.083deg-1x2160x4320-1.0.2_1/data"

metadata = ["project_name","long_name","url"] 
cols_to_record = metadata + ['vname','miny','maxy']
out = pd.DataFrame(columns= cols_to_record)

In [27]:
cols_to_record


Out[27]:
['project_name', 'long_name', 'url', 'vname', 'miny', 'maxy']

In [28]:
for root, sub_dirs, files in os.walk(root_path):
            for sub_dir in sub_dirs:
                sub_dir_path = os.path.join(root_path, sub_dir).replace("\\", "/") 
                file_names = os.listdir(sub_dir_path)
                miny  = 3000
                maxy = 0
                dat = xr.open_dataset(os.path.join(sub_dir_path,file_names[0]))
                metadata_list=[None]*len(cols_to_record)
                metadata_dict = dict()
                cnt = 0
                for key in metadata:
                    try: 
                        metadata_list[cnt]=dat[sub_dir].attrs[key]
                        metadata_dict[cols_to_record[cnt]] = dat[sub_dir].attrs[key]
                    except:
                        print("Err", sub_dir,key)
                        metadata_dict[cols_to_record[cnt]] = None
                    cnt+=1
                for file in file_names:
                    x = int(file[0:4])
                    miny = x if x < miny else miny
                    maxy = x if x > maxy else maxy
                metadata_dict["miny"]=miny
                metadata_dict["maxy"]=maxy
                metadata_dict["vname"]=sub_dir
                tmp = pd.DataFrame(metadata_dict, index=[0])
                out = pd.concat([out,tmp], ignore_index = True)


/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:27: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

Err srex_mask project_name
Err srex_mask url
Err country_mask project_name
Err country_mask long_name
Err country_mask url
/opt/conda/lib/python3.6/site-packages/xarray/backends/netCDF4_.py:319: UserWarning: A segmentation fault may occur when the file path has exactly 88 characters as it does in this case. The issue is known to occur with version 1.2.4 of netCDF4 and can be addressed by upgrading netCDF4 to at least version 1.3.1. More details can be found here: https://github.com/pydata/xarray/issues/1745
  'A segmentation fault may occur when the '

In [29]:
out


Out[29]:
long_name maxy miny project_name url vname
0 Snow Sublimation 2011 2001 GLEAM http://www.gleam.eu snow_sublimation
1 Gross Primary Productivity 2012 2001 FLUXCOM http://www.fluxcom.org/ gross_primary_productivity
2 Black Sky Albedo for Visible Wavebands 2012 1998 GlobAlbedo http://www.globalbedo.org/ black_sky_albedo
3 Precip - RealTime [RT] (see documentation for ... 2015 1980 GPCP http://precip.gsfc.nasa.gov/ precipitation
4 Daily Snow Water Equivalent 2012 1980 GlobSnow http://www.globsnow.info/ snow_water_equivalent
5 Evaporation 2011 2001 GLEAM http://www.gleam.eu evaporation
6 Fraction of Absorbed Photosynthetically Active... 2016 1982 QA4ECV http://www.qa4ecv.eu/ fapar_tip
7 Potential Evaporation 2011 2001 GLEAM http://www.gleam.eu potential_evaporation
8 Directional Hemisphere Reflectance albedo - VI... 2016 1982 QA4ECV - European Union Framework Program 7 http://www.qa4ecv.eu/ black_sky_albedo_avhrr
9 Sensible Heat 2012 2001 FLUXCOM http://www.fluxcom.org/ sensible_heat
10 Aerosol Optical Thickness at 659 nm 2012 2002 ESA Aerosol CCI http://www.esa-aerosol-cci.org/ aerosol_optical_thickness_659
11 Aerosol Optical Thickness at 555 nm 2012 2002 ESA Aerosol CCI http://www.esa-aerosol-cci.org/ aerosol_optical_thickness_555
12 2 metre temperature 2011 2001 ERAInterim http://www.ecmwf.int/en/research/climate-reana... air_temperature_2m
13 Open-water Evaporation 2011 2001 GLEAM http://www.gleam.eu open_water_evaporation
14 Aerosol Optical Thickness at 1610 nm 2012 2002 ESA Aerosol CCI http://www.esa-aerosol-cci.org/ aerosol_optical_thickness_1610
15 Terrestrial or water pixel classification 1980 1980 Climate Change Initiative - European Space Agency http://www.esa-landcover-cci.org water_mask
16 Surface Soil Moisture 2011 2001 GLEAM http://www.gleam.eu surface_moisture
17 Root-Zone Soil Moisture 2011 2001 GLEAM http://www.gleam.eu root_moisture
18 Interception Loss 2011 2001 GLEAM http://www.gleam.eu interception_loss
19 Carbon dioxide emissions due to natural fires ... 2010 2001 GFED4 http://www.globalfiredata.org/ c_emissions
20 Bi-Hemisphere Reflectance albedo - VIS band 2016 1982 QA4ECV - European Union Framework Program 7 http://www.qa4ecv.eu/ white_sky_albedo_avhrr
21 Soil Moisture 2014 1980 SoilMoisture CCI http://www.esa-soilmoisture-cci.org soil_moisture
22 Mask for SREX regions 1980 1980 None None srex_mask
23 Evaporative Stress Factor 2011 2001 GLEAM http://www.gleam.eu evaporative_stress
24 Latent Energy 2012 2001 FLUXCOM http://www.fluxcom.org/ latent_energy
25 Terrestrial Ecosystem Respiration 2012 2001 FLUXCOM http://www.fluxcom.org/ terrestrial_ecosystem_respiration
26 Net Ecosystem Exchange 2012 2001 FLUXCOM http://www.fluxcom.org/ net_ecosystem_exchange
27 Monthly Burnt Area 2014 1995 GFED4 http://www.globalfiredata.org/ burnt_area
28 Aerosol Optical Thickness at 865 nm 2012 2002 ESA Aerosol CCI http://www.esa-aerosol-cci.org/ aerosol_optical_thickness_865
29 Bare Soil Evaporation 2011 2001 GLEAM http://www.gleam.eu bare_soil_evaporation
30 Land Surface Temperature 2011 2002 GlobTemperature http://data.globtemperature.info/ land_surface_temperature
31 Mean total ozone column in dobson units 2011 1996 Ozone CCI http://www.esa-ozone-cci.org/ ozone
32 White Sky Albedo for Visible Wavebands 2012 1998 GlobAlbedo http://www.globalbedo.org/ white_sky_albedo
33 Effective Leaf Area Index 2016 1982 QA4ECV http://www.qa4ecv.eu/ leaf_area_index
34 Surface fraction covered by snow. 2013 2003 GlobSnow http://www.globsnow.info/ fractional_snow_cover
35 Aerosol Optical Thickness at 550 nm 2012 2002 ESA Aerosol CCI http://www.esa-aerosol-cci.org/ aerosol_optical_thickness_550
36 Transpiration 2011 2001 GLEAM http://www.gleam.eu transpiration
37 Total Column Water Vapour 2008 1996 GlobVapour http://www.globvapour.info/ water_vapour
38 None 1980 1980 None None country_mask

In [30]:
plt.rc('xtick',labelsize=14)
plt.rc('ytick',labelsize=12)
out.reset_index()
fig = plt.figure(figsize = [14,14])
plt.title('')
plt.barh(out.index, width=out.maxy-out.miny, left=out.miny, tick_label=out.vname)
plt.tight_layout()
fig.savefig('ESDL_temporal_cover.png')



In [ ]:


In [ ]:


In [ ]:


In [ ]: