Skip to content

Commit

Permalink
MAPEXT 2024.0.18
Browse files Browse the repository at this point in the history
* Bug Fixes
* Minor restructuring of emission models to allow direct recovery of first derivitive
  • Loading branch information
tjrennie committed Mar 12, 2024
1 parent 55fbf46 commit 97b2f06
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mapext/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2024.0.17"
__version__ = "2024.0.18"
__date__ = "11th March 2024"
5 changes: 4 additions & 1 deletion mapext/core/srcClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

__all__ = ['astroSrc']

class astroSrc():
class astroSrc(baseSrc):
"""Class to hold information pertaining to a specific astronomical source. this class is currently aimed at point sources, although will be expanded to be more flexible.
:param name: Source name
:type name: string, optional
:param coords: Center coordinates for the source.
:type coords: list of astropy.coords.SkyCoord or list of floats
:param frame: Coordinate frame if list of floats supplied for coord.
Expand All @@ -21,6 +23,7 @@ class astroSrc():
def __init__(self, **kwargs):
"""Initialisation function.
"""
name = kwargs.get('coords', None)
coords = kwargs.get('coords', None)
frame = kwargs.get('frame', 'galactic')
if isinstance(coords, SkyCoord) == False:
Expand Down
25 changes: 16 additions & 9 deletions mapext/emission/emission_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ class FittableEmissionModel(FittableModel):
n_inputs = 2
n_outputs = 1

@staticmethod
def fit_deriv(*args):
return FittableEmissionModel.deriv(*args)

def deriv(self, nu, beam):
args = []
for _ in self.param_names:
args.append(getattr(self,_).value)
return self.fit_deriv(nu, beam, *args)


# Synchrotron emission model
class synchrotron_1comp(FittableEmissionModel):
Expand Down Expand Up @@ -65,7 +67,8 @@ def evaluate(nu, area, synch_S1, synch_alp):
"""
return synch_S1 * (nu**synch_alp)

def deriv(self,nu, area, synch_S1, synch_alp):
@staticmethod
def fit_deriv(nu, area, synch_S1, synch_alp):
"""Evaluate the first derivitives of emission model with respect to input parameters.
:param nu: Frequency in GHz
Expand Down Expand Up @@ -130,7 +133,8 @@ def evaluate(nu, area, ff_em):
S = 2. * phys_const['k'] * area * np.power(np.multiply(nu,1e9),2) / phys_const['c']**2 * T_ff * 1e26
return S

def deriv(self,nu, area, ff_em):
@staticmethod
def fit_deriv(nu, area, ff_em):
"""Evaluate the first derivitives of emission model with respect to input parameters.
:param nu: Frequency in GHz
Expand Down Expand Up @@ -202,7 +206,8 @@ def evaluate(nu, area, ff_em, ff_Te):
S = 2. * phys_const['k'] * area * np.power(np.multiply(nu,1e9),2) / phys_const['c']**2 * T_ff * 1e26
return S

def deriv(self, nu, area, ff_em, ff_Te):
@staticmethod
def fit_deriv( nu, area, ff_em, ff_Te):
"""Evaluate the first derivitives of emission model with respect to input parameters.
:param nu: Frequency in GHz
Expand Down Expand Up @@ -286,7 +291,8 @@ def evaluate(nu, area, ame_ampl, ame_peak, ame_width):
nmaxlog = np.log(ame_peak)
return ame_ampl*np.exp(-0.5 * ((nlog-nmaxlog)/ame_width)**2)

def deriv(self,nu, area, ame_ampl, ame_peak, ame_width):
@staticmethod
def fit_deriv(nu, area, ame_ampl, ame_peak, ame_width):
"""Evaluate the first derivitives of emission model with respect to input parameters.
:param nu: Frequency in GHz
Expand Down Expand Up @@ -363,7 +369,8 @@ def evaluate(nu, area, tdust_Td, tdust_tau, tdust_beta):
modify = 10**tdust_tau * (nu9/1.2e12)**tdust_beta
return 2 * phys_const['h'] * nu9**3/phys_const['c']**2 /planck * modify * area * 1e26

def deriv(self,nu, area, tdust_Td, tdust_tau, tdust_beta):
@staticmethod
def fit_deriv(nu, area, tdust_Td, tdust_tau, tdust_beta):
"""Evaluate the first derivitives of emission model with respect to input parameters.
:param nu: Frequency in GHz
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[ project ]
name = "mapext"
version = "2024.0.17"
version = "2024.0.18"
authors = [
{ name="Thomas J. Rennie" },
]
Expand Down

0 comments on commit 97b2f06

Please sign in to comment.