OMS-NetZero / FAIR

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

adds common classes for Emissions, Concentrations, Forcings #53

Closed nsfmc closed 11 months ago

nsfmc commented 5 years ago

the classes simplify the rcp_.py files while providing a consistent interface to the data when ingesting arbitrary rcp csv files (i.e. useful in cases where you don't want or need to import all three Emissions/Concentrations/Forcings)

also useful in cases where you need to override specific property behavior (i.e. scaling or reformatting some specific property dynamically)

from fair.RCPs import types

 class SpecialForcing(types.Forcing):                              
     def __init__(self, *args, **kwargs):
         super(SpecialForcing, self).__init__(*args, **kwargs)

     @property
     def year(self):
         return map(int, super(SpecialForcing, self).year.tolist())

this subclassed Forcing would no longer emit an ndarray for years, but instead a simple python list of ints. This is an pretty contrived example, but i think fairly illustrative.

The goal here was to maintain api parity while adding some minor functionality. Tests pass at the same rate as before.

specific additions:

Pull request

Please confirm that this pull request has done the following:

Adding to CHANGELOG.rst

Please add a single line in the changelog notes similar to one of the following:

- (`#XX <http://link-to-pr.com>`_) Added feature which does something
- (`#XX <http://link-to-pr.com>`_) Fixed bug identified in (`#XX <http://link-to-issue.com>`_)
nsfmc commented 5 years ago

if this isn't useful to the project or if it introduces a level of complexity you'd rather not deal with, please feel free to close this pr, mostly submitted to see if it was useful to anybody else.

codecov[bot] commented 5 years ago

Codecov Report

Merging #53 into master will decrease coverage by 9.87%. The diff coverage is 61.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
- Coverage   90.78%   80.91%   -9.88%     
==========================================
  Files          33       34       +1     
  Lines        1270     1074     -196     
==========================================
- Hits         1153      869     -284     
- Misses        117      205      +88
Impacted Files Coverage Δ
fair/RCPs/rcp60.py 100% <100%> (ø) :arrow_up:
fair/RCPs/rcp85.py 100% <100%> (ø) :arrow_up:
fair/RCPs/rcp26.py 100% <100%> (ø) :arrow_up:
fair/RCPs/rcp45.py 100% <100%> (ø) :arrow_up:
fair/RCPs/types.py 58.87% <58.87%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9e5b197...3b45e51. Read the comment docs.

znicholls commented 5 years ago

definitely moves in the right direction for v2.0 @chrisroadmap

chrisroadmap commented 11 months ago

closing as part of general clean and moved beyond this treatment in v2 - thanks all the same :+1:

nsfmc commented 11 months ago

hahaha @chrisroadmap i have zero memory of doing this (it was clearly another time), thanks for closing it out all the same 🤘🏽