项目作者: lloydevans

项目描述 :
A JS interface to the CDS hips2fits service.
高级语言: TypeScript
项目地址: git://github.com/lloydevans/hips2fits-js.git
创建时间: 2020-08-16T13:38:00Z
项目社区:https://github.com/lloydevans/hips2fits-js

开源协议:MIT License

下载


hips2fits-js

hips2fits-js

Simple utility for requesting data from the CDS hips2fits service.

This package provides both ES and CJS module formats.

It is ES5 compatible, however it does not provide any polyfills.

It’s a simple setup - Use the getImage or getImageUrl functions, which take the HipsOptions object.

Documentions on the service can be found here.

alt text

Installation

npm i -S hips2fits-js

Index

Enumerations

Interfaces

Functions

Functions

getImage

getImage(options: HipsOptions, endPoint?: string): Promise‹Uint8Array›

Defined in get-image.ts:59

Get an image from the hips2fits service.

example

  1. const { writeFile } = require("fs").promises;
  2. const {
  3. getImage,
  4. HipsImageFormat,
  5. HipsProjection,
  6. HipsService,
  7. HipsStretch,
  8. HipsCoordsys,
  9. } = require("hips2fits-js");
  10. (async function () {
  11. let data;
  12. try {
  13. data = await getImage({
  14. hips: HipsService.CDS_P_DSS2_color,
  15. coordsys: HipsCoordsys.Icrs,
  16. projection: HipsProjection.Car,
  17. stretch: HipsStretch.Asinh,
  18. format: HipsImageFormat.Png,
  19. width: 2048 / 4,
  20. height: 1024 / 4,
  21. ra: 0,
  22. dec: 0,
  23. fov: 360,
  24. });
  25. await writeFile("image.png", data);
  26. } catch (error) {
  27. console.log(error);
  28. return;
  29. }
  30. })();

Parameters:

Name Type Description
options HipsOptions Options object configuring the Hips image generated.
endPoint? string Base URL endpoint.

Returns: Promise‹Uint8Array›


getImageUrl

getImageUrl(options: HipsOptions, endPoint: string): string

Defined in get-image-url.ts:56

Get an image URL from the hips2fits service.

example

  1. import {
  2. getImageUrl,
  3. HipsImageFormat,
  4. HipsProjection,
  5. HipsService,
  6. HipsStretch,
  7. HipsCoordsys,
  8. } from "hips2fits-js";
  9. let url;
  10. let width = 1024;
  11. let height = 512;
  12. url = getImageUrl({
  13. hips: HipsService.CDS_P_DSS2_color,
  14. coordsys: HipsCoordsys.Icrs,
  15. projection: HipsProjection.Car,
  16. stretch: HipsStretch.Asinh,
  17. format: HipsImageFormat.Png,
  18. width,
  19. height,
  20. ra: 0,
  21. dec: 0,
  22. fov: 360,
  23. });
  24. let img = new Image();
  25. img.width = width;
  26. img.height = height;
  27. img.src = url;
  28. window.addEventListener("load", function () {
  29. window.document.body.appendChild(img);
  30. });

Parameters:

Name Type Default Description
options HipsOptions - Options object configuring the Hips image generated.
endPoint string DEFAULT_ENDPOINT Base URL endpoint.

Returns: string


parseWcs

parseWcs(wcsString: string): WcsDict

Defined in parse-wcs.ts:30

Parse a WCS configuration string.

example

  1. let wcs = `
  2. NAXIS1 = 2000
  3. NAXIS2 = 1000
  4. WCSAXES = 2 / Number of coordinate axes
  5. CRPIX1 = 1000.0 / Pixel coordinate of reference point
  6. CRPIX2 = 500.0 / Pixel coordinate of reference point
  7. CDELT1 = -0.18 / [deg] Coordinate increment at reference point
  8. CDELT2 = 0.18 / [deg] Coordinate increment at reference point
  9. CUNIT1 = 'deg' / Units of coordinate increment and value
  10. CUNIT2 = 'deg' / Units of coordinate increment and value
  11. CTYPE1 = 'GLON-MOL' / galactic longitude, Mollweide's projection
  12. CTYPE2 = 'GLAT-MOL' / galactic latitude, Mollweide's projection
  13. CRVAL1 = 0.0 / [deg] Coordinate value at reference point
  14. CRVAL2 = 0.0 / [deg] Coordinate value at reference point
  15. `;
  16. let wcsDict = parseWcs(wcs);

Parameters:

Name Type Description
wcsString string

Returns: WcsDict