ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
122 stars 77 forks source link

Opening MEF image file #311

Open AlexaVillaume opened 8 years ago

AlexaVillaume commented 8 years ago

Hi all,

This is a very basic question but I can't figure out how to open a MEF image such that all the extensions are displayed at the same time. I'm thinking of something similar to "open other" in DS9. Right now when I load the image it just displays one extension. I'd appreciate it if somebody could help me out.

Thank you, Alexa

pllim commented 8 years ago

Use the MultiDim local plugin. Then choose the extension(s) you want to open.

AlexaVillaume commented 8 years ago

Thanks @pllim for your reply but still a little confused. There's the drop down menu on the left where I can only select one extension at a time and there's the display on the right where, again, I can only go through one extension at a time. What's the secret handshake for getting all the extensions to display at once?

screen shot 2016-03-28 at 9 53 29 am
pllim commented 8 years ago

Good question. File->Open and FBrowser accept wildcard in filename to open multiple files at once, but they do not support wildcard in the extension specification (the square brackets).

AlexaVillaume commented 8 years ago

Does that mean I cannot open all the extensions of the file at once?

On Mar 28, 2016, at 10:26 AM, P. L. Lim notifications@github.com wrote:

Good question. File->Open and FBrowser accepts wildcard in filename to open multiple files at once, but they do not support wildcard in the extension specification (the square brackets).

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ejeschke/ginga/issues/311#issuecomment-202496212

pllim commented 8 years ago

There might be a way that I am not aware of. @ejeschke ? Or perhaps @eteq knows how to accomplish this using Jupyter notebook magic?

pllim commented 8 years ago

Thinking about this a bit more, I am not sure if it is a desirable feature to have Ginga automatically open all extensions. While it might be convenient in your case, some files have mixed image/table/header format, which means Ginga will fail to load some of them. And also, what if someone provides a file with hundreds of extensions?

ejeschke commented 8 years ago

Hi @AlexaVillaume !

It would be quite straightforward to add a button to MultiDim that would open all HDU's (ideally just image HDUs, I guess). MultiDim uses astropy.io.fits to open the file and assigns this to the instance variable self.fits_f. So the callback for the button would just iterate over then length of this and load all image HDUs. There is even a function called set_hdu() which takes an index and loads the HDU corresponding to that index if it is not already loaded.

If would be great if you'd want to take a stab at a PR for that--it really would be just a few lines of python. If not, LMK here and I'll do it.

ejeschke commented 8 years ago

Oh, BTW, what I described is for loading a series of images in the same channel (window), so that you can pick them from the Thumbs or Contents. If you want to open them in all different windows, that's also pretty easy, but requires a couple extra steps.

ejeschke commented 8 years ago

You can see in build_gui() how to add a button and give it a callback.

AlexaVillaume commented 8 years ago

Hi @ejeschke! I will try to implement the button.

pllim commented 8 years ago

Just thinking out loud here -- Should we put in safe guard to disable that new button if the image has too many of extensions? The "too many" can be an arbitrary number that is user configurable or hard-coded. Or maybe it does not matter unless user has set numImages = 0?

ejeschke commented 8 years ago

Some limit would be good, I guess. "ramp" frames can have hundreds of large images.

ejeschke commented 7 years ago

@pllim, now that we have the --sep option, should we consider to make it open a MEF file in separate windows? Or should we use a different option? We could also maybe add an "Open MEF" menu option to do the same.

pllim commented 7 years ago

open a MEF file in separate windows

@ejeschke , in a way that is already possible. The command below would open each extension of the same file in a separate channel:

ginga --loglevel=40 --stderr --sep ua3u0101m_c0m.fits[1] ua3u0101m_c0m.fits[2] ua3u0101m_c0m.fits[3] ua3u0101m_c0m.fits[4]
ejeschke commented 7 years ago

The command below would open each extension of the same file in a separate channel @pllim, True, but a bit cumbersome to write!

What about a notation like:

$ ginga --loglevel=40 --stderr --sep ua3u0101m_c0m.fits[*]

or

$ ginga --loglevel=40 --stderr --sep ua3u0101m_c0m.fits[2-5]
pllim commented 7 years ago

@ejeschke , I thought about it but not sure if it is possible to validate or expand the extensions without actually opening the files first.

pllim commented 5 years ago

@AlexaVillaume , do you want to try again with the latest master? As a side effect of #742, your use case might work now. For example, I have this FITS file:

No.    Name      Ver    Type      Cards   Dimensions   Format
  0  PRIMARY       1 PrimaryHDU     239   ()      
  1  SCI           1 ImageHDU        93   (4096, 2048)   float32   
  2  ERR           1 ImageHDU        46   (4096, 2048)   float32   
  3  DQ            1 ImageHDU        38   (4096, 2048)   int16   
  4  SCI           2 ImageHDU        93   (4096, 2048)   float32   
  5  ERR           2 ImageHDU        46   (4096, 2048)   float32   
  6  DQ            2 ImageHDU        38   (4096, 2048)   int16 

ginga filename.fits[*] loaded these extensions all at once:

So if your file does not have any EXTVER=2, this basically loads all the extensions in your file.