OMS-NetZero / FAIR

Finite-amplitude Impulse Response simple climate model
https://docs.fairmodel.net
Apache License 2.0
123 stars 62 forks source link

Install .pickle file as well #21

Closed rgieseke closed 6 years ago

rgieseke commented 6 years ago

With the "pickle" file added I'm getting a file not found error when installing directly from GitHub

pip install https://github.com/OMS-NetZero/FAIR/archive/v1.2_dev.zip
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-5-08823b14a483> in <module>()
----> 1 C26, F26, T26 = fair.forward.fair_scm(emissions=rcp3pd.Emissions.emissions)

~/Work/test/venv/lib/python3.6/site-packages/fair/forward.py in fair_scm(emissions, other_rf, q, tcrecs, d, a, tau, r0, rc, rt, F2x, iirf_max, tcr_dbl, C_pi, restart_in, restart_out, F_volcanic, F_solar, aviNOx_frac, fossilCH4_frac, natural, efficacy, scale, oxCH4_frac, ghg_forcing, stwv_from_ch4, b_aero, b_tro3, useMultigas, useStevenson, lifetimes, aerosol_forcing, scaleAerosolAR5, fixPre1850RCP, useTropO3TFeedback)
    229       if 'ghan' in aerosol_forcing.lower():
    230         F[:,8] = F[:,8] + aerosols.ghan_indirect_emulator(emissions,
--> 231           scale_AR5=scaleAerosolAR5)
    232     else:
    233       raise ValueError("aerosol_forcing should be one of 'stevens', "+

~/Work/test/venv/lib/python3.6/site-packages/fair/forcing/aerosols.py in ghan_indirect_emulator(emissions, fix_pre1850_RCP, scale_AR5)
    121     # http://atucla.blogspot.co.uk/2016/01/save-and-load-rbf-object-fromto-file.html
    122     RBFfile = open(os.path.join(os.path.dirname(__file__),
--> 123         'ghan_emulator.pickle'),'rb')
    124     if sys.version_info > (3,0):
    125         RBFunpickler = pickle.Unpickler(RBFfile, encoding='latin1')

FileNotFoundError: [Errno 2] No such file or directory: '/Users/robert/Work/test/venv/lib/python3.6/site-packages/fair/forcing/ghan_emulator.pickle'

It seems adding include_package_data=True in setup.py fixes that.

http://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files

See also here: https://stackoverflow.com/questions/7522250/how-to-include-package-data-with-setuptools-distribute

Seriously, I feel like this ticket is a group therapy session for folks using setuptools and discovering just what a horrid place they have found themselves in life.

(StackOverflow)

It seems to be complicated. :-)

chrisroadmap commented 6 years ago

@rgieseke thanks again for going above and beyond with testing the model! I hope this wasn't too much work, as I have now dropped the dependence on the radial basis function so I no longer use the pickle. Using a functional fit was less prone to error, is more transparent, and quicker to calculate. At least we know in future that we have to consider the impact on setup.py for every new thing that we introduce...

rgieseke commented 6 years ago

@chrisroadmap Thanks! Was not problem testing this and works now. (I've been struggling with these install issues in other projectst …)