Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hscmap/fits

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hscmap/fits

fits (Flexible Image Transport System) reader module

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Introduction

  • Working demo

Example (Source code of the working demo)

import { Fits, Hdu } from "@hscmap/fits"
const sampleFitsURL = require<string>('file-loader!./sample.fits')


window.addEventListener('load', async e => {
    const fits = await Fits.fetch(sampleFitsURL, [
        { outputDataType: Fits.DataType.uint8 },
        { outputDataType: Fits.DataType.uint8 },
    ])

    for (const hdu of fits) {
        showHdu(hdu)
    }
})


function showHdu(hdu: Hdu) {
    const width = hdu.card('NAXIS1', 'number')
    const height = hdu.card('NAXIS2', 'number')

    const canvas = document.createElement('canvas')
    const ctx = canvas.getContext('2d')!
    canvas.width = width
    canvas.height = height

    const imagedata = ctx.createImageData(width, height)
    hdu.uint8array(array => {
        for (let y = 0; y < height; ++y) {
            for (let x = 0; x < width; ++x) {
                const i = y * width + x
                const j = (height - y) * width + x
                const value = array[i]
                imagedata.data[4 * j] = value
                imagedata.data[4 * j + 1] = value
                imagedata.data[4 * j + 2] = value
                imagedata.data[4 * j + 3] = 255
            }
        }
    })
    ctx.putImageData(imagedata, 0, 0)
    document.body.appendChild(canvas)

    const pre = document.createElement('pre')
    pre.innerText = JSON.stringify(hdu.header, undefined, 2)
    document.body.appendChild(pre)

    document.body.appendChild(document.createElement('hr'))
}

See also

Keywords

FAQs

Package last updated on 08 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc