Code Monkey home page Code Monkey logo

healpix's Introduction

HEALPix

Introduction

This module is an implementation of HEALPix in TypeScript. A Javascript version is available as well. (Typescript is a typed superset of Javascript, that compiles to Javascript.)

This package was implemented based on the description in the HEALPix paper. Pixelisation-related functions (including corners) and disk query are available for the ring and nested HEALPix pixelisation schemes. Most API interfaces are ported from wonderful healpy Python package, and tests against healpy are used to show correctness.

The following sections explain installation and usage, and give examples. Detailed API documentation is also available.

Limitations

  • This package can handle only norder <= 15.

Installation and Usage

With NPM

If you are using Node.js, you can download and install @hscmap/healpix with npm:

npm install --save @hscmap/healpix

Then from your Javascript (JS) you can require and use healpix like this:

const healpix = require('@hscmap/healpix');
console.log(healpix.order2nside(0));

From Typescript import and use it like this:

import * as healpix from '@hscmap/healpix';
console.log(healpix.order2nside(0));

Standalone JS

Another option is to use healpix.js as a standalone library.

Thanks to the unpkg CDN, you can simply add this line to your HTML file:

<script src="https://unpkg.com/@hscmap/healpix@latest/standalone/dist/healpix.js"></script>

and after that line you can call healpix functions like this:

<script>
console.log(healpix.order2nside(0));
</script>

If you don't want to use the latest version, select one from here.

Examples

Examples using healpix are available here: http://michitaro.github.io/healpix/

The code is available here:

Instructions how to build the examples locally are in the next section.

Developer documentation

To hack on this package, clone https://github.com/michitaro/healpix from Github:

git clone https://github.com/michitaro/healpix.git
cd healpix

Then run npm install to install the tools and dependencies used (especially Typescript and Webpack):

npm install

The package is implemented in a single Typescript file: src/index.ts.

To generate the standalone Javascript package standalone/dist/healpix.js, run this command:

npm run standalone

To compile and run the examples locally:

npm run build-example

To test the package install Python and healpy first, and then run:

npm run my-test

Feedback, issues and contributions welcome: https://github.com/michitaro/healpix

See Also

License

This software is released under the MIT License, see LICENSE.

healpix's People

Contributors

cdeil avatar dependabot[bot] avatar michitaro avatar

Stargazers

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

Watchers

 avatar  avatar

healpix's Issues

How deep?

Do you know how deep this module can go. Will it go beyond a nside of 13?

Clarify x/y vs p/q

@michitaro - I'm still in the process of reading the HEALPix papers, using your code to try to fully understand.

This list of variable names and descriptions is very helpful:
https://github.com/michitaro/healpix/blob/master/src/index.ts#L4

You do sometimes use x/y, but those are not defined in the list.
Note that you have tu2fpq and fxy2tu, so maybe x/y and p/q are the same?

Is it possible to make the notation more consistent; or to clarify what x/y are in that list?

Document how to use as a JS library?

@michitaro - I'm completely new to Typescript and pretty new to JS, so apologies for the basic question.

How can one use this library as a simple JS library from a HTML web page?

I did this to generate src/index.js

git clone https://github.com/michitaro/healpix.git
cd healpix
npm install -g typescript
tsc src/index.ts 

and then made an example.html with this:

<script src="src/index.js"></script>
<script>
var result = healpix.ang2pix(12, 42, 43);
console.log(result);
<script>

but then in the browser I get these errors:

Uncaught ReferenceError: exports is not defined
    at index.js:18
example.html:3 Uncaught ReferenceError: healpix is not defined
    at example.html:3

@michitaro - is use as simple JS library something you want to support?
If yes, could you please document the steps and give a minimal example how to do it?
Is it a good or bad idea to store the generated healpix.js in the repo to make this easier?

Algorithm in disk query?

@michitaro - Is the algorithm you use for disk query described somewhere?
(a webpage or paper?)

If no, could you please add a few comments to the docstring to make it easier to understand what it does?

export function query_disc_inclusive_nest(nside: number, v: V3, radius: number, cb: (ipix: number) => void) {

License?

@michitaro - Hi, I was looking for a TS / JS HEALPix package, thinking to write one, and now see that you've already done it. Awesome, thanks!

One question concerning license: is it really MIT?
The original C++ lib is GPL, so I assume you didn't copy from there?

API docs?

Hi, I'm new to Typescript.

Is there a way to generate API docs?

I see https://github.com/michitaro/healpix#progress but to be able to use it I have to look at the code what the inputs / outputs are. Is that how it's usually done for Typescript?

If there is a way to add docs and you want it here, this could be something I contribute to a bit while I familiarise myself with TS and this package?

Latest version not published

Hey Koike,

Thanks for the package - I'm playing around with visualizing some CMB data and find it really useful. Just a quick question - the latest version does not seem to be published to npm. I can work around it by building locally, but thought I would just let you know.

norder limitation

Hi,

I'm using healpix for a different project, and have been looking around for implementations and came across yours which seems interesting. However, the limitation is at norder <= 15. Current norder doesn't allow high resolution images of nebulas for example when overlaying different frequency image survey maps (infrared, nir, xray etc). Can you tell me what the exact reason for this is? I might be able to help somehow.

I downloaded healpix 3.8 and the doc provides a healpix2 cpp that allows for much higher resolutions, which indicates that the norder can be increased?

Any pointers to the reasons of the limitations greatly appreciated as I can further investigate.

Maximum supported order?

@michitaro - What is the maximum supported norder?

I see 16 here:

for norder in range(16):

Why is that?

Naively I would think that orders up to 24 can be supported, given that JS has numbers that can represent int up to 53 bit:

>>> import healpy as hp
>>> hp.nside2npix(hp.order2nside(24)) / (2 ** 53)
0.375

I think healpy supports up to order 29, because they have 64 bit integers available.

>>> import healpy as hp
>>> hp.nside2npix(hp.order2nside(29))
3458764513820540928
>>> hp.nside2npix(hp.order2nside(29)) / (2 ** 64)
0.1875

CC @tboch

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.