Skip to content

ndfpack: return masked arrays if there is a Starlink BADVAL defined for the type.#4

Open
sfgraves wants to merge 5 commits into
Starlink:masterfrom
sfgraves:master
Open

ndfpack: return masked arrays if there is a Starlink BADVAL defined for the type.#4
sfgraves wants to merge 5 commits into
Starlink:masterfrom
sfgraves:master

Conversation

@sfgraves

Copy link
Copy Markdown
Member

In the current version of ndfpack, bad pixel vals in all arrays (data, var, and other extensions) are left as the Starlink bad pixel value for the datatype of the array. This requires the user to find out the BAD pixel value of their data type and filter the array themselves before they can perform most analysis tasks.

These commits instead:
a) add a function to ndf.c to get the Starlink type of a component (this was done by reusing code in the read function, so this may not have been the optimal way to implement this.)

b) alters the ndfpack.py NDF class init to return numpy masked arrays if the Starlink badvalue exists for the data type. The data, var and extension components are all affected by this.

Function to get the Starlink type (as a string) of a specific
component of an ndf file.
Mask out any data points with the Starlink BADPIXVAL for that
data type.
@dsberry

dsberry commented Mar 23, 2016

Copy link
Copy Markdown
Member

I've not used pyndf for a long time, and then only minimally. Is there any chance that changing the array components to numpy masked arrays will have any effect on existing code that uses pyndf?

@sfgraves

Copy link
Copy Markdown
Member Author

Its not guaranteed to never require changing existing code, but a lot of things will just work (and possibly be better, as they will now handle code with missing data values more sensibly). The line from the numpy.ma documentation is:

"The numpy.ma module provides a nearly work-alike replacement for numpy that supports data arrays with masks."

so make of that what you will...

I did a quick google, and the only publicly available code I found using this module at all was in smurf (jsatilemoc), and a script of Erik Rosolowsky ( https://github.com/low-sky/py-jcmt/blob/master/scanflag.py). Do we know of any more? I don't know of anyone using the module for personal scripts at EAO, and I've not come across any users who know much about it.

@timj

timj commented Mar 23, 2016

Copy link
Copy Markdown
Member

I'm fine with merging this (assuming SMURF is fixed) so long as there are also change log updates somewhere.

ndf_getbadpixval will fail on components with type=None in python3, so
protect against that.
Specifically logging the fact that ndfpack is now returning
masked numpy arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants