Skip to content

Commit

Permalink
WIP refactor + fixes + github actions + readme
Browse files Browse the repository at this point in the history
  • Loading branch information
francoismg committed Mar 19, 2024
1 parent 95a0591 commit 1315d92
Show file tree
Hide file tree
Showing 24 changed files with 2,549 additions and 455 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/npm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish to npm

on:
push:
branches:
- npm-repository

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install npm
run: sudo apt-get install npm -y

- name: Publish to npm
env:
TOKEN: ${{secrets.token}}
run: |
cd dist/fits-reader
npm publish
25 changes: 25 additions & 0 deletions .github/workflows/webpack-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build Library

on:
push:
branches:
- prod

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Build library
run: npx webpack
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# fits-reader
---
FITS reader library
---


Javascript library for parsing FITS file

**Usage**

<script src="fits-reader.js"></script>
<script>

function getFile(file_path) {
return fetch(file_path)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error, status = ${response.status}`);
}
return response.arrayBuffer();
}).then((buffer) => readFile(buffer));
}
function readFile(arrayBuffer) {
//FITS file object containing the file headers and data units
//Library entry point expects a FITS file array buffer
let fits_file = window.FITSReader.parseFITS(arrayBuffer);
//Position of the header and data unit
let hdu_index = 1;

let hdu = fits_file.getHDU(hdu_index);
let header = hdu.header;
let data = hdu.data;
let card_name = "CARDNAME";

//Get a specific card value
let card_value = header.get(card_name);
let col_name = "column";

//Specific to BINTABLE and TABLE extension
let col_data;
data.getColumn(col_name, function(col){col_data = col});
}

//Get array buffer from file
getFile("file.fits");
</script>



2 changes: 2 additions & 0 deletions dist/fits-reader/fits-reader.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions dist/fits-reader/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "fits-reader",
"version": "1.0.0",
"description": "Javascript library for reading FITS file",
"main": "fits-reader.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT"
}
1 change: 0 additions & 1 deletion dist/fits.js

This file was deleted.

Loading

0 comments on commit 1315d92

Please sign in to comment.