×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Missing BUNIT header in fits files coming from Ekos?

  • Posts: 49
  • Thank you received: 4
Hi all,

I'm trying to write my own Python pipelines to calibrate, platesolve and stack FITS files. My acquisition setup is:
  • QHY163-M / QHYCFW-2 / QHY-5-II (guider) / EQMod (EQ6)
  • indiserver ran via indi-web on a Raspberry Pi
  • Kstars/Ekos with local patesolving

In my script, I load all files in a ccdproc collection and try to iterate on it like this:
for img, fname in collection.ccds(return_fname=True):
But then I get the following error:
ValueError: a unit for CCDData must be specified.

From what I've read here , this seems to be due to a missing BUNIT header in the FITS file. So I've wrote the following workaround:
    for hdu in collection.hdus(overwrite=True):
        hdu.header['bunit'] = 'adu'
        hdu.header.pop('radecsys', None)
        hdu.header['radesys'] = 'FK5'
The problem is that it somehow resets the "created at" value of the FITS file and generally feels like bad practice.

So my question(s) is (are): Are we really missing a BUNIT header or is my code wrong? If we're missing it, is there a way to tell Ekos to write it in?
Bonus question: Say I wanted to run each newly acquired FITS file through a simple pipeline (write the BUNIT value and update the WCS with a freshly solved one), what would be the best way to do it?

Thanks!
Last edit: 1 year 10 months ago by Adrien Barrajon.
1 year 10 months ago #82863

Please Log in or Create an account to join the conversation.

We don't have BUNIT in the headers and apparently it's not really important since no one complained for a long time. What value should it be if added? ADU?
1 year 10 months ago #82867

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 4
I really don't know anything about how standard that header is, as I've only learned its existence when seeing that error I'm getting from my Python scripts. I solved it by creating the header with the value "adu", so that's what worked for me.

Here is the paragraph about this header in the FITS standard:
KEYWORD:   BUNIT
REFERENCE: FITS Standard 
STATUS:    reserved
HDU:       image
VALUE:     string
COMMENT:   physical units of the array values
DEFINITION: The value field shall contain a character string,
describing the physical units in which the quantities in the array,
after application of BSCALE and BZERO, are expressed.   The units of
all FITS header keyword values, with the exception of measurements of
angles, should conform with the recommendations in the IAU Style
Manual. For angular measurements given as floating point values and
specified with reserved keywords, degrees are the recommended units
(with the units, if specified, given as 'deg').

My understanding is that the value would pretty much always be "adu" for all uses specific to consumer-grade astronomical cameras. Maybe in some research environment a camera can be directly counting individual photons, but for what we all do here it should be "adu".
1 year 10 months ago #82870

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 104
The keyword in this list are only "reserved", this meant they cannot be used with another signification.
But they are not mandatory and processing software must expect they are not present. In fact I never see any capture software that add this keyword because it make some sens only after calibration to some physical flux units.

Instead of adding a dummy value like "adu" it is better to report that to astro-pipelines so it can be fixed to work without this keyword.
The following user(s) said Thank You: Jasem Mutlaq, Peter Sütterlin
1 year 10 months ago #82872

Please Log in or Create an account to join the conversation.

  • Posts: 49
  • Thank you received: 4
I am the one who wrote astro-pipelines and I'm not sure how to fix that! As I explain on the post above, my workaround is to actually write that header down before loading any collection with ccdproc.

Maybe the right way to work it out is to have a part of my pipelines automatically running on each captured frame freshly coming out of Ekos? But then I'm not sure how to properly implement this. Would the best way to have it done through the "post-capture script" hook on Ekos? Or with a separate script that monitors new files in the folder and processes them?
1 year 10 months ago #82873

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 104
Sorry, I jump to your second post too quickly.

Anyway the problem is with ccdproc, there is already an issue for that: github.com/astropy/astropy/issues/10977
A proposed solution is to add a default value for BUNIT, I not follow further to see if the proposed solution was merged.
1 year 10 months ago #82879

Please Log in or Create an account to join the conversation.

Time to create page: 0.696 seconds