GithubHelp home page GithubHelp logo

brampf / fitscore Goto Github PK

View Code? Open in Web Editor NEW
21.0 5.0 5.0 19.23 MB

A native Swift library to read and write FITS files

License: MIT License

Swift 100.00%
swift fits swift-linux swift-library swift5 file-format fits-files fits-parse swift-package file-format-library

fitscore's Introduction

Stars Twitter


FitsRaw now on Testflight!

FitsRaw is a leightweight viewer app for your iPad to view files in the [FITS file format](https://fits.gsfc.nasa.gov) commonly used in Astrophotography. For more information about the FITS file format head over to [NASA](https://fits.gsfc.nasa.gov/fits_documentation.html) of have a look ad [Wikipedia](https://en.wikipedia.org/wiki/FITS)

FitsRaw is currently availabe on Testflight. In order to join, just click ot the following URL: https://testflight.apple.com/join/Hr2K1Wg8


  • Open FITS files and renders an image for the data unit of the primary HDU as image data
  • Auto-detection of Grayscale, RGB and RGGB image data (particularly for the ZWO ASI294MC camera)
  • Display the content of the header unit for the currently selected HDU
  • Preliminary rendering of tables (Bintable only only display the first value of an array)
  • Placeholder for empty HDUs or Image HDUs with less than 1 or more than 3 dimensions
  • Rendering of thumbnails for the data unit of the primary HDU of FITS files in the file browser
  • Rendering of preview for the data unit of the primary HDU for apples quicklook

FITS Raw currently supports only iPad OS and is tested with a rather old & slow iPad 5 on iPad OS 14.5.

For the latest updates and your feedback please see Discussions

FITSCore FITSKit
FITSCore FITSKit

Java Swift Rust

fitscore's People

Contributors

brampf avatar fischerbach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fitscore's Issues

Package manager import not working

Hi,

First off thanks for this great module, it will really help me take a lot of server code out and put it into my app's client side functionality.

I've just finished a Swift wrapper for the MAST API https://github.com/triple7/SwiftMAST

I am at the point of testing product downloads and file manipulation using FITSCore.

Just followed the instructions but I get the 2 errors below:
SwiftMAST, 3 issues
dependency 'fitscore' is not used by any target
product 'FITS' required by package 'swiftmast' target 'SwiftMAST' not found.
FITS, Error
No such module 'FITS'

The relevant portions are:

            targets: ["SwiftMAST"]),
    ],
    dependencies: [
        .package(url: "https://github.com/brampf/fitscore", .upToNextMajor(from: "0.3.0")),    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "SwiftMAST",
            dependencies: ["FITS"]),

Hopefully I can get an answer as I'm working starting Tuesday and would like to have this package completed before then haha

Happy new year :)

Getting values from a BINTABLE

I'm gettting compile time errors at the starred lines using FITSKit to see a BINTABLE:

     if let tableHDU = hdus[i] as? AnyTableHDU<BFIELD> {
                            for i in 0..<tableHDU.tfields! {
                                print("\(i) - \(tableHDU.columns[i].TTYPE!)")
                                print("\(i) - \(tableHDU.columns[i].TUNIT!)")
                                print("\(i) - \(tableHDU.columns[i].TFORM!)")
                            }
                            print(tableHDU.columns[1][2])        ***
                            print(tableHDU.rows[1][2])              ***
                            tableHDU.rows.forEach { row in
                                var  out = ""
                                    for col in 0..<row.values.count{
                                        let field:BFIELD = row.values[1] 
                                        out.append(col.format(row.TDISP(col)) ?? "N/A")).        ***
                                    }
                                    print(out)
                            }
                        }

Any idea what's going on? Thanks for any info ...

  • Tod

Implement CHECKSUM

Implementation of the CHECKSUM keyword according to the standard Appendix J

FITSByte_* normalization returns wrong values

The method should use bigEndian, perhaps also the property float!

This returns a very high value for a linear FITS image:
public func normalize(_ bzero: Float = 0, _ bscale: Float = 1, _ min: FITSByte_16 = .min, _ max: FITSByte_16 = .max) -> Float {
return (bzero + Float(self) * bscale) / Self.range
}

This would return the correct value:
public func normalize(_ bzero: Float = 0, _ bscale: Float = 1, _ min: FITSByte_16 = .min, _ max: FITSByte_16 = .max) -> Float {
return (bzero + Float(self.bigEndian) * bscale) / Self.range
}

Improve implementation for random groups

"Random-groups structures" are currently not fully implemented but skipped over instead. To fully complete the implementation of the 4.0 Standard, PrimaryHDU should be extended by some high-level code to handle those structures

Header validation error

Hi,
I'm using the library to validate an existing fits file, but I get an error message that I don't understand:
"Data contains 9 bytes but supposed to be 24385536 bytes"

I don't understand the validation code that triggers this error. In AnyHDU.swift:
if modified == false && headerUnit.count < headerUnit.dataSize {

It looks like it is comparing two different things, the number of items in the header and the number of bytes in the data ?

Have I missed something ?

Documentation update needed

Since with all the syntactic sugar and especially with the changes made with the new parser, the documentation needs an update. Especially on

  • Reading whole files
  • Reading / writing header keywords

Improve validation Code

The validation routines are currently very limited and do not cover many cases. It should be a piece of cake to implement most if not all of the rule for FITSverify(https://heasarc.gsfc.nasa.gov/docs/software/ftools/fitsverify/):

SEVERE ERROR CONDITIONS

  • Mandatory keyword not present or out of order
  • Mandatory keyword has wrong datatype or illegal value
  • END header keyword is not present
  • Sum of table column widths is inconsistent with NAXIS1 value
  • BLANK keyword present in image with floating-point datatype
  • TNULLn keyword present for floating-point binary table column
  • Bit column has non-zero fill bits or is not left adjusted(*)
  • ASCII TABLE column contains illegal value inconsistent with TFORMn(*)
  • Address to a variable length array not within the data heap(*)
  • Extraneous bytes in the FITS file following the last HDU

ERROR CONDITIONS

  • Mandatory keyword values not expressed in fixed format
  • Mandatory keyword duplicated elsewhere in the header
  • Header contains illegal ASCII character (not ASCII 32 - 126)
  • Keyword name contains illegal character
  • Keyword value field has illegal format
  • Value and comment fields not separated by a slash character
  • END keyword not filled with blanks in columns 9 - 80
  • Reserved keyword with wrong datatype or illegal value
  • XTENSION keyword in the primary array
  • Column related keyword (TFIELDS, TTYPEn,TFORMn, etc.) in an image
  • SIMPLE, EXTEND, or BLOCKED keyword in any extension
  • BSCALE, BZERO, BUNIT, BLANK, DATAMAX, DATAMIN keywords in a table
  • Table WCS keywords (TCTYPn, TCRPXn, TCRVLn, etc.) in an image
  • TDIMn or THEAP keyword in an ASCII table
  • TBCOLn keyword in a Binary table
  • THEAP keyword in a binary table that has PCOUNT = 0
  • XTENSION, TFORMn, TDISPn or TDIMn value contains leading space(s)
  • WCSAXES keyword appears after other WCS keywords
  • Index of any WCS keyword (CRPIXn, CRVALn, etc.) greater than value of WCSAXES
  • Index of any table column descriptor keyword (TTYPEn, TFORMn, etc.) greater than value of TFIELDS
  • TSCALn or TZEROn present for an ASCII, logical, or Bit column
  • TDISPn value is inconsistent with the column datatype
  • Length of a variable length array greater than the maximum length as given by the TFORMn keyword
  • ASCII table floating-point column value does not have decimal point(*)
  • ASCII table numeric column value has embedded space character
  • Logical column contains illegal value not equal to 'T', 'F', or 0(*)
  • Character string column contains non-ASCII text character(*)
  • Header fill bytes not all blanks (**)
  • Data fill bytes not all blanks in ASCII tables or all zeros in any other type of HDU (**)
  • Gaps between defined ASCII table columns contain characters with ASCII value > 127 (**)

WARNING CONDITIONS

  • SIMPLE = F
  • Presence of deprecated keywords BLOCKED or EPOCH
  • 2 HDUs have identical EXTNAME and EXTVER values
  • BSCALE or TSCALn value = 0.
  • BLANK OR TNULLn value exceeds the legal range
  • TFORMn has 'rAw' format and r is not a multiple of w
  • DATE = 'dd/mm/yy' and yy is less than 10 (Y2K problem??)
  • Index of any WCS keyword (CRPIXn, CRVALn, etc.) greater than value of NAXIS, if the WCSAXES keyword is not present
  • Duplicated keyword (except COMMENT, HISTORY, blank, etc.)
  • Column name (TTYPEn) does not exist or contains characters other than letter, digit and underscore
  • Binary table has PCOUNT > 0, but no variable-length array columns
  • Calculated checksum inconsistent with CHECKSUM or DATASUM keyword(***)
  • The HEASARC long string keyword convention is used without the recommended LONGSTRN keyword (****)

(*) only checked when "testdata" is 'Yes'
(**) only checked when "testdata" and "testfill" are 'Yes'
(***) only checked when "testdata" and "tchksum" are 'Yes'
(****) only checked when the "heasarc" is 'Yes'

Every HDU in the FITS file is checked in turn until the end of file is detected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.