In [2]:
import coordination1
import commentjson

In [3]:
my_settings = {'git_dir':'/home/stephan/Repos/scripts/','cordex_dir':'/home/stephan/Repos/cordex/','output_dir':'/home/stephan/Repos/IS-ENES-Data.github.io/'}

In [6]:
jsonfile = "/media/sf_Repos/ENES-EUDAT/cordex/CORDEX_adjust_register.json"

def load_bias_sheet(jsonfilename):
        jsonfile = open(jsonfilename,"r")
        json_string = jsonfile.read()
        print json_string
        #parser = JsonComment(json)
        jsonfile.close()
        #json_dict = parser.loads(json_info)
        json_dict = commentjson.loads(json_string)
        return json_dict

In [10]:
json_string = """
{
"1":
{ "institution":  "Swedish Meteorological and Hydrological Institute",
  "institute_id": "SMHI",
  "contact": "rossby.cordex@smhi.se",
  "bc_method": "Distribution-Based Scaling",
  "bc_method_id": "DBS45",
  "reference": "Yang et al. 2010, doi:10.2166/nh.2010.004",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44; WAS-44",
  "terms_of_use": "unrestricted",
  "package": "na"
},

"2":
{ "institution":  "Technical University of Crete",
  "institute_id": "TUC",
  "contact": "manolis@hydromech.gr",
  "bc_method": "Multisegment Statistical Bias correction",
  "bc_method_id": "MSBC",
  "reference": "Grillakis et al. 2013,  doi:10.1002/jgrd.50323",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44; WAS-44",
  "terms_of_use": "unrestricted",
  "package": "na"
  },

"3":
{ "institution":  "Meteorology Group, Universidad de Cantabria",
  "institute_id": "UCAN",
  "contact": "Sixto Herrera, herrerasd@unican.es ",
  "bc_method": "Seasonally Adjusted Empirical Quantile Mapping",
  "bc_method_id": "EQM",
  "reference": "Déqué 2007, doi:10.1007/s00704-013-0834-z; Wilcke et al. 2013, doi: 10.1007/s10584-013-0845-x",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44",
  "terms_of_use": "unrestricted",
  "package": "downscaleR package for R, https://github.com/SantanderMetGroup/downscaleR"
  },

 "4":
{ "institution":  "Meteorology Group, Universidad de Cantabria",
  "institute_id": "UCAN",
  "contact": "Sixto Herrera, herrerasd@unican.es ",
  "bc_method": "ISI-MIP",
  "bc_method_id": "ISI-MIP",
  "reference": "Hempel et al. 2013, doi:10.1007/s10584-013-0845-x",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44",
  "terms_of_use": "unrestricted",
  "package": "downscaleR package for R, https://github.com/SantanderMetGroup/downscaleR"
  },
  
"5":
{ "institution":  "Norwegian Meteorological Institute",
  "institute_id": "METNO",
  "contact": "Andreas Dobler, andreas.dobler@met.no",
  "bc_method": "Quantile mapping",
  "bc_method_id": "QMAP",
  "reference": "Gudmundsson et al. 2012, doi:10.5194/hess-16-3383-2012",
  "CORDEX_domain": "EUR-44; EUR-11",
  "terms_of_use": "unrestricted",
  "package": "qmap package for R, v. 1.0-3"
},

"6":
{ "institution":  "Institut Pierre Simon Laplace",
  "institute_id": "IPSL",
  "contact": "na",
  "bc_method": "Cumulative Distribution Function",
  "bc_method_id": "CDFT21",
  "reference": "Vrac et al. 2016, doi:10.1002/2015JD024511",
  "CORDEX_domain": "EUR-11",
  "terms_of_use": "unrestricted",
  "package": "na"
}

}
"""

In [18]:
json_string = """
{
"1":
{ "institution":  "Swedish Meteorological and Hydrological Institute",
  "institute_id": "SMHI",
  "contact": "rossby.cordex@smhi.se",
  "bc_method": "Distribution-Based Scaling",
  "bc_method_id": "DBS45",
  "reference": "Yang et al. 2010, doi:10.2166/nh.2010.004",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44; WAS-44",
  "terms_of_use": "unrestricted",
  "package": "na"
},

"2":
{ "institution":  "Technical University of Crete",
  "institute_id": "TUC",
  "contact": "manolis@hydromech.gr",
  "bc_method": "Multisegment Statistical Bias correction",
  "bc_method_id": "MSBC",
  "reference": "Grillakis et al. 2013,  doi:10.1002/jgrd.50323",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44; WAS-44",
  "terms_of_use": "unrestricted",
  "package": "na"
  }
}
"""

In [19]:
json_dict = json_dict = commentjson.loads(json_string)

In [8]:
res = load_bias_sheet(jsonfile)


# Registration of methods for bias adjustment of CORDEX simulations

{
"1":
{ "institution":  "Swedish Meteorological and Hydrological Institute",
  "institute_id": "SMHI",
  "contact": "rossby.cordex@smhi.se",
  "bc_method": "Distribution-Based Scaling",
  "bc_method_id": "DBS45",
  "reference": "Yang et al. 2010, doi:10.2166/nh.2010.004",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44; WAS-44",
  "terms_of_use": "unrestricted",
  "package": "na"
},

"2":
{ "institution":  "Technical University of Crete",
  "institute_id": "TUC",
  "contact": "manolis@hydromech.gr",
  "bc_method": "Multisegment Statistical Bias correction",
  "bc_method_id": "MSBC",
  "reference": "Grillakis et al. 2013,  doi:10.1002/jgrd.50323",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44; WAS-44",
  "terms_of_use": "unrestricted",
  "package": "na"
  },

"3":
{ "institution":  "Meteorology Group, Universidad de Cantabria",
  "institute_id": "UCAN",
  "contact": "Sixto Herrera, herrerasd@unican.es ",
  "bc_method": "Seasonally Adjusted Empirical Quantile Mapping",
  "bc_method_id": "EQM",
  "reference": "Déqué 2007, doi:10.1007/s00704-013-0834-z; Wilcke et al. 2013, doi: 10.1007/s10584-013-0845-x",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44",
  "terms_of_use": "unrestricted",
  "package": "downscaleR package for R, https://github.com/SantanderMetGroup/downscaleR"
  },

 "4":
{ "institution":  "Meteorology Group, Universidad de Cantabria",
  "institute_id": "UCAN",
  "contact": "Sixto Herrera, herrerasd@unican.es ",
  "bc_method": "ISI-MIP",
  "bc_method_id": "ISI-MIP",
  "reference": "Hempel et al. 2013, doi:10.1007/s10584-013-0845-x",
  "CORDEX_domain": "EUR-44; EUR-11; AFR-44",
  "terms_of_use": "unrestricted",
  "package": "downscaleR package for R, https://github.com/SantanderMetGroup/downscaleR"
  },
  
"5":
{ "institution":  "Norwegian Meteorological Institute",
  "institute_id": "METNO",
  "contact": "Andreas Dobler, andreas.dobler@met.no",
  "bc_method": "Quantile mapping",
  "bc_method_id": "QMAP",
  "reference": "Gudmundsson et al. 2012, doi:10.5194/hess-16-3383-2012",
  "CORDEX_domain": "EUR-44; EUR-11",
  "terms_of_use": "unrestricted",
  "package": "qmap package for R, v. 1.0-3"
},

"6":
{ "institution":  "Institut Pierre Simon Laplace",
  "institute_id": "IPSL",
  "contact": "na",
  "bc_method": "Cumulative Distribution Function",
  "bc_method_id": "CDFT21",
  "reference": "Vrac et al. 2016, doi:10.1002/2015JD024511",
  "CORDEX_domain": "EUR-11",
  "terms_of_use": "unrestricted",
  "package": "na"
}

}

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-8-d21a8537e62f> in <module>()
----> 1 res = load_bias_sheet(jsonfile)

<ipython-input-6-26f853025716> in load_bias_sheet(jsonfilename)
      8         jsonfile.close()
      9         #json_dict = parser.loads(json_info)
---> 10         json_dict = commentjson.loads(json_string)
     11         return json_dict

/home/snki/miniconda3/envs/py27/lib/python2.7/site-packages/commentjson/commentjson.pyc in loads(text, **kwargs)
     69     regex = r'\s*(#|\/{2}).*$'
     70     regex_inline = r'(:?(?:\s)*([A-Za-z\d\.{}]*)|((?<=\").*\"),?)(?:\s)*(((#|(\/{2})).*)|)$'
---> 71     lines = text.split('\n')
     72 
     73     for index, line in enumerate(lines):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1086: ordinal not in range(128)

In [5]:
my_cv = coordination1.CV_Gen(my_settings)


/home/stephan/Repos/cordex/CORDEX_register.xlsx

In [ ]:


In [6]:
print my_cv


<coordination1.CV_Gen object at 0x7f5901a3e950>

Dependencies: esgf-pyclient mako markdown


In [7]:
import markdown
class MD(str):
    def _repr_html_(self):
        return markdown.markdown(self)

In [9]:
from IPython.core.display import display,HTML
line = my_cv.print_cv(output_format='html',outputfile='CORDEX_RCMs_info.html')

test1 = HTML(line)
#print test1
display(test1)


---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-9-f800eb991fb1> in <module>()
      1 from IPython.core.display import display,HTML
----> 2 line = my_cv.print_cv(output_format='html',outputfile='CORDEX_RCMs_info.html')
      3 
      4 test1 = HTML(line)
      5 #print test1

/home/stephan/Repos/scripts/Scripts/coordination1.pyc in print_cv(self, output_format, outputfile)
    182             line = make_html_table(self.cv_sheet,timestamp)
    183             #print line
--> 184             cv_file.write(line)
    185 
    186         cv_file.close()

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 2718: ordinal not in range(128)

In [11]:



Model Name Institute Terms of Use Institution Name
AUTH-LHTEE-WRF321B AUTH-LHTEE nan nan AUTH-Met-WRF331A AUTH-Met nan nan AWI-HIRHAM5 AWI nan Alfred Wegener Institute, Helmholtz Centre for Polar and Marine Research BCCR-WRF331 BCCR unrestricted Uni Research and the Bjerknes Centre for Climate Research BCCR-WRF331C BCCR unrestricted Uni Research and the Bjerknes Centre for Climate Research BCCR-WRF361 BCCR unrestricted Uni Research and the Bjerknes Centre for Climate Research CCCma-CanRCM4 CCCma unrestricted CCCma (Canadian Centre for Climate Modelling and Analysis, Victoria, BC, Canada) CHMI-ALADIN52 CHMI nan nan CLMcom-CCLM4-8-17 CLMcom non-commercial only Climate Limited-area Modelling Community (CLM-Community) CNRM-ALADIN52 CNRM unrestricted Centre National de Recherches Meteorologiques CNRM-ALADIN53 CNRM non-commercial only Centre National de Recherches Meteorologiques CNRM-ARPEGE52 CNRM unrestricted Centre National de Recherches Meteorologiques CRP-GL-WRF331A CRP-GL unrestricted nan CSIRO-CCAM CSIRO nan Commonwealth Scientific and Industrial Research Organisation CUNI-RegCM4-2 CUNI nan nan DHMZ-RegCM4-2 DHMZ non-commercial only Meteorological and Hydrological Service of Croatia DMI-HIRHAM5 DMI unrestricted nan ENEA-RegCM4-3 ENEA non-commercial only Italian National Agency for New Technologies, Energy and Sustainable Economic Development GISS-RM3 GISS nan NASA Goddard Institute for Space Studies (GISS) HMS-ALADIN52 HMS non-commercial only Hungarian Meteorological Service ICTP-RegCM4-3 ICTP unrestricted Abdus Salam International Centre for Theoretical Physics IDL-WRF331D IDL nan nan IITM-RegCM4-1 IITM non-commercial only Indian Institute of Tropical Meteorology IPSL-INERIS-WRF331F IPSL-INERIS nan nan KAUST-GFDL KAUST nan King Abdullah University, Thuwal, Saudi Arabien KNMI-RACMO21P KNMI unrestricted Royal Netherlands Meteorological Institute, De Bilt, The Netherlands KNMI-RACMO22E KNMI unrestricted Royal Netherlands Meteorological Institute, De Bilt, The Netherlands KNMI-RACMO22T KNMI unrestricted Royal Netherlands Meteorological Institute, De Bilt, The Netherlands MIUB-WRF331A MIUB nan nan MOHC-HadGEM3-RA MOHC unrestricted Met Office Hadley Centre MOHC-HadRM3P MOHC unrestricted Met Office Hadley Centre MPI-CSC-REMO2009 MPI-CSC unrestricted Helmholtz-Zentrum Geesthacht, Climate Service Center, Max Planck Institute for Meteorology NUIM-WRF341E NUIM non-commercial only National University of Ireland Maynooth SMHI-RCA4 SMHI unrestricted Swedish Meteorological and Hydrological Institute, Rossby Centre SMHI-RCA4-SN SMHI unrestricted Swedish Meteorological and Hydrological Institute, Rossby Centre SMHI-RCAO SMHI unrestricted Swedish Meteorological and Hydrological Institute, Rossby Centre SMHI-RCAO-SN SMHI unrestricted Swedish Meteorological and Hydrological Institute, Rossby Centre UCAN-WRF331G UCAN non-commercial only nan UCAN-WRF350I UCAN nan nan UCLM-PROMES UCLM nan University of Castilla-La Mancha, Toledo, Spain UHOH-WRF361H UHOH non-commercial only University of Hohenheim UM-WRF331 UM nan nan UNSW -WRF-R1 UNSW unrestricted University of New South Wales UNSW -WRF-R2 UNSW unrestricted University of New South Wales UNSW -WRF-R3 UNSW unrestricted University of New South Wales UQAM-CRCM5 UQAM unrestricted Universite du Quebec a Montreal

In [ ]: