ICSM / ampere

A tool to fit the SED and spectra of dusty objects to constrain, among other things, the dust properties and mineralogy
6 stars 2 forks source link

Apply fitting only to a subset of the data #31

Closed ciskakemper closed 2 years ago

ciskakemper commented 3 years ago

Following the description by Srinivasan et al. (2017), I want to fit the IRS spectrum only over the observed 8-35 micron range complemented with any photometry available at longer wavelengths (PACS or MIPS-70). This means that in pgQuasarSample.py I need to select a subset of the data in 'irs" and a subset of the data in 'phot' for the fitting. Perhaps this can be done as an additional argument to EmCeeSearch.

pscicluna commented 3 years ago

I have added a method to the data classes in 488e01289314692c9cb410ca597a34bf46d6bc44 which I hope will be sufficient for this.

The method masks the data in each Data object internally based on wavelength, with the user specifying any of the limits of the interval and how to treat the edges of the interval. It defaults to including the edges in the data to be used. Simply call phot.selectWaves(low = value, up = value, interval = "kind-of-interval") (if your data object is phot; all arguments are optional) and the object will update its internal mask for the new values. For a list of data, call: for data in dataset: data.selectWaves(inputs) to get the same behaviour. This should work any time after reading the data from file and before running the fit. If this works we can close the issue.

pscicluna commented 3 years ago

I've been looking into fixing this. Masked arrays present two issues:

  1. They're about 5 times slower than regular arrays because they execute mainly in pure python rather than in C
  2. They behave differently to regular arrays when performing linear algebra on them.

As a result, it looks like the best approach is still a very hacky solution, but it should work. Basically, the original data will have to be copied to duplicate variables, and only the data not masked out will be in the variables used to do calculations. the unmask() method will then simply delete the masks and return the original data to prominence.

pscicluna commented 2 years ago

I think this is fixed, so closing for now. Please reopen if problems appear.