-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement regularized inversion method of Hannah and Kontar (2012) #19
Comments
I have a write-up of the code that could be a nice starting point as documentation for this. |
That'd be great. We should think about how we want to structure the documentation and this would be a nice test case for that |
Yes, if we can figure out a docs structure I can start looking at adding things. |
I created #20 to have this discussion since the scope is outside of just this method. |
I used @alasdairwilson's version of class HK12Model(GenericModel):
def _model(self, alpha=1.0, increase_alpha=1.5, max_iterations=10, guess=None, return_em=False):
errors = np.array([c.uncertainty.array.squeeze() for c in self.data]).T
dem,edem,elogt,chisq,dn_reg=dn2dem_pos(
self.data_matrix.value.T,
errors,
self.kernel_matrix.value.T,
np.log10(self.temperature_bin_centers.to(u.K).value),
self.temperature_bin_edges.to(u.K).value,
max_iter=max_iterations,
reg_tweak=alpha,
rgt_fact=increase_alpha,
dem_norm0=guess,
)
dem_unit = self.data_matrix.unit / self.kernel_matrix.unit / self.temperature_bin_edges.unit
dem = dem * dem_unit
edem = edem * dem_unit
if return_em:
delta_t = np.diff(self.temperature_bin_edges)
dem = dem * delta_t
edem = edem * delta_t
return dem.T, edem.T
@classmethod
def defines_model_for(self, *args, **kwargs):
return kwargs.get('model') == 'hk12' Ideally this would of course be a PR, but there are some things we should think about:
|
I think it makes sense to have
Yes, I think it should have that functionality
Yes, agreed. |
I can make this into its own issue (unsure if it's a When implementing this method with sunkit-dem/sunkit_dem/base_model.py Line 153 in 9a439c9
For the following 3D sequence >>> seq.data[0].dimensions
[1, 50, 50] pix >>> seq.data[0].wcs
WCSAXES = 3 / Number of coordinate axes
CRPIX1 = 35.372013038278 / Pixel coordinate of reference point
CRPIX2 = 65.40190861244 / Pixel coordinate of reference point
CRPIX3 = 1.0 / Pixel coordinate of reference point
... where the In the 1D and 0D cases, the following is observed: >>> slice_1d = seq.index_as_cube[0:6,pix_lat,:]
>>> slice_1d.data[0].dimensions
[1, 50] pix
>>> slice_1d.data[0].wcs.to_header()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-55-863c7d91680f> in <module>
----> 1 slice_0d.data[0].wcs.to_header()
AttributeError: 'HighLevelWCSWrapper' object has no attribute 'to_header' as Unsure if there is an easy workaround here, but thought I'd mention before opening an issue |
Thanks for pointing this out. This is constantly an issue when dealing with sliced WCSs. Now that ndcube 2.0 is out and stable, we should really revisit all of that code (that I originally wrote against ndcube 1.x). |
Are we now in a position to integrate this method? |
The regularized inversion method of Hannah and Kontar (2012) is one of the most popular and widely used DEM inversion methods, particularly with AIA data.
There are both Python and IDL implementations:
From discussions with @alasdairwilson, it seems that the Python version is extremely fast and matches the output of the original IDL code quite well and so would be an excellent candidate for trying out in this framework.
The text was updated successfully, but these errors were encountered: