emolter / pylanetary

data processing and modeling tools for ring, moon, and planet observations
GNU General Public License v3.0
8 stars 6 forks source link

Spectral extraction code #29

Open dahlek opened 1 year ago

dahlek commented 1 year ago

make a code that extracts spectra from images as a function of lat/long/mu, number of bins, etc.

dahlek commented 1 year ago

hmu for my spectral extraction stuff made mostly from legacy Nemesis IDL programs

emolter commented 1 year ago

Hi @dahlek , thanks for submitting this PR! This is something we would love to include in pylanetary. If I understand correctly what this piece of code would do, it would take in a lat-lon or emission angle range of interest, and then make an average spectrum within that range. Is that right? If so, this could definitely take advantage of the navigation.ModelBody class for doing the lat/lon/mu geometry. We have been wanting to improve support for spectral cubes for a while now, and it would be awesome if you could help with that. @sloughran97 is starting to work on extracting Doppler winds and has started a new namespace called pylanetary.spectral, so if you make support for spectral cubes you could use the same. Perhaps you could keep each other in the loop as you start to implement support for spectral cubes?

dahlek commented 1 year ago

Sounds good! I'm new to collaborating on github but I'll see if I can't pull together a bit of a rough draft.

emolter commented 1 year ago

cool let me know if you want to discuss how to implement this in detail, or the workflows with git

dahlek commented 1 year ago

@emolter starting a draft version of this, for now meant to help a student extract spectra from SpeX images but I'm planning on keeping things as generic as possible/keeping track of the things to change: https://github.com/dahlek/spextraction

emolter commented 1 year ago

sounds great! although I don't see any code on the GitHub page yet. @sloughran97 has started working on generic spectrum tools on a fork of the pylanetary repo, but I don't think a draft has been publicly uploaded yet. I'll ping her and see if she is willing to open a draft pull request; it might save you some work getting your tool working for your student.

emolter commented 1 year ago

Here is Sarah's fork

sloughran97 commented 1 year ago

Let me know if you have any questions! I think it'll be great to collaborate on the spectral extraction utilities.

dahlek commented 1 year ago

Hey @sloughran97, looks like your fork mostly contains code to fit a line shape. I'm working on something to extract spectra of a given type (e.g. disk-averaged, binned, etc.) from an image, put it in user-defined units (e.g. I/F or radiance), and put it into a desired format to be used as input for something (for now it'll just be nemesis). Were you working on something similar? Or are there parts of your current fork that should be used for that? If so we should make sure we don't reinvent each other's wheels; otherwise I'll cruise ahead with "spextraction"

dahlek commented 1 year ago

Mostly I need to write this anyways for a student at JPL, so once it's done we can see how/if we can merge stuff together

sloughran97 commented 1 year ago

I don't currently have plans to include any functionalities like that, so you should be good to go. Let's be sure to communicate though, I imagine there will be a lot of opportunities to use our contributions in tandem. We can make sure they merge together smoothly.

On Thu, Aug 10, 2023, 5:10 PM Emma Dahl @.***> wrote:

Mostly I need to write this anyways for a student at JPL, so once it's done we can see how/if we can merge stuff together

— Reply to this email directly, view it on GitHub https://github.com/emolter/pylanetary/issues/29#issuecomment-1673924608, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6RYJ7IVJYFN6CRJOUVS333XUVE33ANCNFSM6AAAAAA2WIQNIA . You are receiving this because you were mentioned.Message ID: @.***>

emolter commented 1 year ago

@dahlek for spatial averaging of a spectrum, you may want to make use of utils.convolve_with_beam, which allows convolution of a 2-D field with a 2-D Gaussian or arbitrary PSF. We also already have a function for computing I/F from erg s-1 cm-2 um-1.

dahlek commented 1 year ago

@emolter okay excellent, will do. One small comment, dunno if it's worth a whole fork, it would be good to mention on line 301 in utils that the fluxes for I/F should be calibrated already.