Skip to content

Commit

Permalink
Merge pull request #482 from xpsi-group/254-unit-tests-for-hotregion
Browse files Browse the repository at this point in the history
254 unit tests for hotregion
  • Loading branch information
DevarshiChoudhury authored Dec 6, 2024
2 parents e005273 b8060cd commit 87ae76a
Show file tree
Hide file tree
Showing 10 changed files with 670 additions and 58 deletions.
28 changes: 9 additions & 19 deletions docs/source/Hot_region_complexity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 194,7 @@
" num_leaves=100,\n",
" num_rays=200,\n",
" do_fast=False,\n",
" is_secondary=True,\n",
" is_antiphased=True,\n",
" prefix='s')\n",
"\n",
"from xpsi import HotRegions\n",
Expand Down Expand Up @@ -676,9 676,7 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -762,9 760,7 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -939,9 935,7 @@
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -1017,9 1011,7 @@
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -1086,9 1078,7 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -1197,7 1187,7 @@
" num_leaves=100,\n",
" num_rays=200,\n",
" do_fast=False,\n",
" is_secondary=True,\n",
" is_antiphased=True,\n",
" prefix='s')\n",
"\n",
"from xpsi import HotRegions\n",
Expand Down Expand Up @@ -1685,9 1675,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
8 changes: 4 additions & 4 deletions docs/source/Surface_radiation_field_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 835,7 @@
" num_leaves=100,\n",
" num_rays=200,\n",
" do_fast=False,\n",
" is_secondary=True,\n",
" is_antiphased=True,\n",
" atm_ext=\"BB\",#default blackbody, other options: \"Num4D\" or \"user\" \n",
" prefix='s')\n",
"\n",
Expand Down Expand Up @@ -1075,7 1075,7 @@
" num_leaves=100,\n",
" num_rays=200,\n",
" do_fast=False,\n",
" is_secondary=True,\n",
" is_antiphased=True,\n",
" atm_ext=\"Num4D\",#default blackbody, other options: \"Num4D\" or \"user\" \n",
" prefix='s')\n",
"\n",
Expand Down Expand Up @@ -1314,9 1314,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
8 changes: 3 additions & 5 deletions docs/source/old/Multiple_imaging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 816,7 @@
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -2221,7 2219,7 @@
" num_leaves=1024,\n",
" num_phases=100,\n",
" num_rays=1024,\n",
" is_secondary=False,\n",
" is_antiphased=False,\n",
" prefix='p')\n",
"\n",
"bounds = dict(super_colatitude = (0.001, math.pi - 0.001),\n",
Expand Down Expand Up @@ -2839,5 2837,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
2 changes: 1 addition & 1 deletion examples/examples_fast/Modules/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 111,7 @@
max_sqrt_num_cells=64,
num_leaves=64,
num_rays=512,
is_secondary=True,
is_antiphased=True,
image_order_limit=3, # up to tertiary
prefix='p') # For "primary"

Expand Down
6 changes: 3 additions & 3 deletions examples/examples_fast/Sampling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 453,7 @@
" max_sqrt_num_cells=64,\n",
" num_leaves=64,\n",
" num_rays=512,\n",
" is_secondary=True,\n",
" is_antiphased=True,\n",
" image_order_limit=3, # up to tertiary\n",
" prefix='hot')\n"
]
Expand Down Expand Up @@ -838,9 838,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
33 changes: 9 additions & 24 deletions xpsi/HotRegion.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 147,6 @@ class HotRegion(ParameterSubspace):
region (``super`` region or an ``omit`` region) then the centre
of that region is the point that is *aligned* to a meridian.
:param bool is_secondary:
Deprecated. You can use or the ``is_antiphased`` keyword argument
instead, which has precisely the same effect.
.. note::
The parameters are as follows:
Expand Down Expand Up @@ -272,7 268,7 @@ def __init__(self,
image_order_limit = None,
**kwargs):

self.is_antiphased = kwargs.get('is_secondary', is_antiphased)
self.is_antiphased = is_antiphased

self.do_fast = do_fast

Expand All @@ -289,6 285,9 @@ def __init__(self,
self.image_order_limit = image_order_limit

self._split = split
if not isinstance(self._split, bool):
raise TypeError("The 'split' argument signifies split atmosphere interpolation and must be a boolean.")

self.symmetry = symmetry

self.atm_ext = atm_ext
Expand Down Expand Up @@ -518,7 517,6 @@ def symmetry(self, declaration):
raise TypeError('Declare symmetry existence with a boolean.')

self._symmetry = declaration

# find the required integrator
if declaration: # can we safely assume azimuthal invariance?
if self._split:
Expand Down Expand Up @@ -725,23 723,18 @@ def num_cells(self):
return self._num_cells

@property
def is_secondary(self):
""" Shift the hot region by half a rotational cycle? Deprecated. """
def is_antiphased(self):
""" Shift the hot region by half a rotational cycle? """
return self._is_antiphased

@is_secondary.setter
def is_secondary(self, is_secondary):
@is_antiphased.setter
def is_antiphased(self, is_antiphased):
if not isinstance(is_antiphased, bool):
raise TypeError('Use a boolean to specify whether or not the '
'hot region should be shifted by half a cycle.')
else:
self._is_antiphased = is_antiphased

@property
def is_antiphased(self):
""" Shift the hot region by half a rotational cycle? """
return self._is_antiphased

@property
def atm_ext(self):
""" ... """
Expand Down Expand Up @@ -782,14 775,6 @@ def beam_opt(self, option):
raise TypeError('Got an unrecognised beam_opt argument. Note that the only allowed '
'beam_opt options are 0, 1, 2, 3 (see documentation).')

@is_antiphased.setter
def is_antiphased(self, is_antiphased):
if not isinstance(is_antiphased, bool):
raise TypeError('Use a boolean to specify whether or not the '
'hot region should be shifted by half a cycle.')
else:
self._is_antiphased = is_antiphased

def print_settings(self):
""" Print numerical settings. """
print('Base number of cell parallels: ', self.sqrt_num_cells)
Expand Down
2 changes: 1 addition & 1 deletion xpsi/Parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 96,7 @@ def __call__(self, boundto, caller = None):
num_leaves=100,
num_rays=200,
do_fast=False,
is_secondary=True,
is_antiphased=True,
prefix='s')
from xpsi import HotRegions
Expand Down
Loading

0 comments on commit 87ae76a

Please sign in to comment.