Skip to content

Commit

Permalink
Merge pull request #122 from brian-rose/insolation2D
Browse files Browse the repository at this point in the history
Implement 2D seasonal insolation for EBM
  • Loading branch information
brian-rose committed Jan 15, 2020
2 parents a8b6286 + dd6d075 commit 23ce3ba
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion climlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
has been documented for a comprehensive understanding and traceability.
'''

__version__ = '0.7.6.dev2'
__version__ = '0.7.6.dev3'

# this should ensure that we can still import constants.py as climlab.constants
from .utils import constants, thermo, legendre
Expand Down
7 changes: 6 additions & 1 deletion climlab/radiation/insolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,16 @@ def _compute_fixed(self):
pass

def _get_current_insolation(self):
# this probably only works for 1D (latitude) domains
insolation_array = self.insolation_array
# make sure that the diagnostic has the correct field dimensions.
dom = self.domains['default']
time_index = self.time['day_of_year_index'] # THIS ONLY WORKS IF self IS THE MASTER PROCESS
insolation = insolation_array[..., time_index]
if 'lon' in dom.axes:
# insolation is latitude-only, need to broadcast across longitude
# assumption is axes are ordered (lat, lon, depth)
# NOTE this is a clunky hack and all this will go away
# when we use xarray structures for these internals
insolation = np.tile(insolation[...,np.newaxis], dom.axes['lon'].num_points)
self.insolation[:] = Field(insolation, domain=dom)
self.coszen[:] = self._coszen_from_insolation()
11 changes: 11 additions & 0 deletions climlab/tests/test_domain2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ def test_2D_EBM():
# Test the xarray interface
m.to_xarray()

@pytest.mark.fast
def test_2D_EBM_seasonal():
'''Can we step forward a 2D seasonal lat/lon EBM?'''
#state = climlab.surface_state(num_lon=4)
#m = climlab.EBM_annual(state=state)
m = climlab.EBM_seasonal(num_lon=4)
m.step_forward()
assert m.state.Ts.shape == (90, 4, 1)
# Test the xarray interface
m.to_xarray()

@pytest.mark.fast
def test_2D_insolation():
#state = climlab.surface_state(num_lon=4)
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "0.7.6.dev2" %}
{% set version = "0.7.6.dev3" %}

package:
name: climlab
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import print_function
import os

VERSION = '0.7.6.dev2'
VERSION = '0.7.6.dev3'

# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
# properly updated when the contents of directories change (true for distutils,
Expand Down

0 comments on commit 23ce3ba

Please sign in to comment.