Source: public/javascript/modules/utils.js

  1. import { SPEED_OF_LIGHT, VELOCITY_SHIFT_TYPE, REDSHIFT_SHIFT_TYPE } from "./constants.js";
  2. /*
  3. ** A set of classes and function definitions utilized by the
  4. ** differents flavours of OLQV viewers.
  5. **
  6. ** Author : M. Caillat
  7. ** Date : 06th December 2018
  8. ** 07th April 2021
  9. */
  10. /*
  11. ** A class to convert a right ascension expressed in decimal degree into an integer value expressing a pixel index.
  12. */
  13. class RADDtoPixelConverter {
  14. static enter(what) {
  15. console.group(this.name + "." + what);
  16. }
  17. static exit() {
  18. console.groupEnd();
  19. }
  20. constructor(radd0, radd1, rapix0, rapix1) {
  21. RADDtoPixelConverter.enter(this.constructor.name);
  22. this.radd0 = radd0;
  23. this.rapix0 = rapix0;
  24. this.slope = (rapix1 - rapix0) / (radd1 - radd0);
  25. RADDtoPixelConverter.exit();
  26. }
  27. convert(radd) {
  28. RADDtoPixelConverter.enter(this.convert.name);
  29. var result = this.rapix0 + (radd - this.radd0) * this.slope;
  30. RADDtoPixelConverter.exit();
  31. return result;
  32. }
  33. }
  34. /*
  35. ** A class to convert a declination expressed in decimal degree into an integer value expressing a pixel index.
  36. */
  37. class DECDDtoPixelConverter {
  38. static enter(what) {
  39. console.group(this.name + "." + what);
  40. }
  41. static exit() {
  42. console.groupEnd();
  43. }
  44. constructor(decdd0, decdd1, decpix0, decpix1) {
  45. DECDDtoPixelConverter.enter(this.constructor.name);
  46. this.decdd0 = decdd0;
  47. this.decpix0 = decpix0;
  48. this.slope = (decpix1 - decpix0) / (decdd1 - decdd0);
  49. DECDDtoPixelConverter.exit();
  50. }
  51. convert(decdd) {
  52. DECDDtoPixelConverter.enter(this.convert.name);
  53. var result = this.decpix0 + (decdd - this.decdd0) * this.slope;
  54. DECDDtoPixelConverter.exit();
  55. return result;
  56. }
  57. };
  58. class PixelToAbsConverter {
  59. static enter(what) {
  60. console.group(this.name + "." + what);
  61. }
  62. static exit() {
  63. console.groupEnd();
  64. }
  65. /**
  66. *
  67. * @param {integer} crpix1 the reference pixel along the first axis ( supposedly RA )
  68. * @param {float} cdeltInDeg1 the coordinate increment in degree at the reference point along the first axis ( supposedly RA )
  69. * @param {integer} crpix2 the reference pixel along the second axis ( supposedly DEC )
  70. * @param {float} cdeltInDeg2 the coordinate increment in degree at the reference point along the second axis ( supposedly DEC )
  71. * @param {Projection} projection the instance of Projection deduced from the FITS header.
  72. */
  73. constructor(crpix1, cdeltInDeg1, crpix2, cdeltInDeg2, projection) {
  74. this.crpix1 = crpix1;
  75. this.cdeltInRad1 = cdeltInDeg1 * Math.PI / 180.;
  76. this.crpix2 = crpix2;
  77. this.cdeltInRad2 = cdeltInDeg2 * Math.PI / 180.;
  78. this.projection = projection;
  79. }
  80. /**
  81. *
  82. * @param {integer} i an integer expressing the first pixel coordinate on the pixels grid ( supposedly RA )
  83. * @param {integer} j an integer expressing the second pixel coordinate on the pixels grid ( supposedly DEC )
  84. * @returns {float[2]} [<right-ascension-in-degree>, <declination-in-degree>]
  85. */
  86. convert(i, j) {
  87. let aux = this.projection.relToAbs([(i - this.crpix1) * this.cdeltInRad1], [(j - this.crpix2) * this.cdeltInRad2]);
  88. return ([aux['ra'][0] * 180 / Math.PI, aux['dec'][0] * 180 / Math.PI]);
  89. }
  90. /**
  91. * @param {integer} i an integer expressing the first pixel coordinate on the pixels grid ( supposedly RA )
  92. * @param {integer} j an integer expressing the second pixel coordinate on the pixels grid ( supposedly DEC )
  93. * @returns {String[2]} [<string-HMS>, <string-DMS>]
  94. */
  95. label(i, j) {
  96. let [raInDeg, decInDeg] = this.convert(i, j);
  97. return [DecDeg2HMS(raInDeg), DecDeg2DMS(decInDeg)];
  98. }
  99. }
  100. class AbsToPixelConverter {
  101. static enter(what) {
  102. console.group(this.name + "." + what);
  103. }
  104. static exit() {
  105. console.groupEnd();
  106. }
  107. /**
  108. *
  109. * @param {integer} crpix1 the reference pixel along the first axis ( supposedly RA )
  110. * @param {float} cdelt1 the coordinate increment in radians at the reference point along the first axis ( supposedly RA )
  111. * @param {integer} crpix2 the reference pixel along the second axis ( supposedly DEC )
  112. * @param {float} cdelt2 the coordinate increment in radians at the reference point along the second axis ( supposedly DEC )
  113. * @param {Projection} projection the instance of Projection deduced from the FITS header.
  114. */
  115. constructor(crpix1, cdelt1, crpix2, cdelt2, projection) {
  116. this.crpix1 = crpix1;
  117. //degrees to radians
  118. this.cdelt1 = degToRad(cdelt1);
  119. this.crpix2 = crpix2;
  120. // degrees to radians
  121. this.cdelt2 = degToRad(cdelt2);
  122. this.projection = projection;
  123. }
  124. /**
  125. *
  126. * @param {float} x right ascension in radian
  127. * @param {float} y right ascention in radian
  128. * @returns {integer[2]} [<pixel-first-coordinate>, <pixel-second-coordinate>]
  129. */
  130. convert(x, y) {
  131. let aux = this.projection.absToRel([x], [y]);
  132. let i = this.crpix1 + ((aux["x"][0] / this.cdelt1) - 1);
  133. let j = this.crpix2 + ((aux["y"][0] / this.cdelt2) - 1);
  134. return ([Math.round(i), Math.round(j)]);
  135. }
  136. }
  137. class PixelToDECConverter {
  138. static enter(what) {
  139. console.group(this.name + "." + what);
  140. }
  141. static exit() {
  142. console.groupEnd();
  143. }
  144. /**
  145. *
  146. * @param {*} refpos CRVAL3
  147. * @param {*} refchannel CRPIX3
  148. * @param {*} angularoffset CDELT3
  149. */
  150. constructor(refpos, refchannel, angularoffset) {
  151. this.crval3 = refpos;
  152. this.crpix3 = refchannel;
  153. this.cdelt3 = angularoffset;
  154. }
  155. /**
  156. *
  157. * @param {*} pix
  158. */
  159. convert(pix) {
  160. var result = this.crval3 + (pix - this.crpix3) * this.cdelt3;
  161. return result;
  162. }
  163. };
  164. class PixelToRAConverter {
  165. static enter(what) {
  166. console.group(this.name + "." + what);
  167. }
  168. static exit() {
  169. console.groupEnd();
  170. }
  171. /**
  172. *
  173. * @param {*} refpos CRVAL1
  174. * @param {*} refchannel CRPIX1
  175. * @param {*} angularoffset CDELT1
  176. * @param {*} dec DEC in degree
  177. */
  178. constructor(refpos, refchannel, angularoffset, dec) {
  179. this.crval1 = refpos;
  180. this.crpix1 = refchannel;
  181. this.cdelt1 = angularoffset;
  182. }
  183. /**
  184. * static enter(what) {
  185. console.group(this.name + "." + what);
  186. }
  187. static exit() {
  188. console.groupEnd();
  189. }
  190. * @param {*} pix
  191. */
  192. convert(pix, dec) {
  193. let dec_inrad = (dec * Math.PI) / 180;
  194. var result = this.crval1 + (pix - this.crpix1) * this.cdelt1 / Math.cos(dec_inrad);
  195. return result;
  196. }
  197. };
  198. /*
  199. ** Converts a decimal number expected to represent an angle in degree
  200. ** into a string expressing a right ascension ( H:M:S)
  201. */
  202. var DecDeg2HMS = function(deg, sep = ':') {
  203. //if(any(deg< 0 | deg>360)){stop('All deg values should be 0<=d<=360')}
  204. //if (deg < 0)
  205. //deg[deg < 0] = deg[deg < 0] + 360
  206. const HRS = Math.floor(deg / 15);
  207. const MIN = Math.floor((deg / 15 - HRS) * 60);
  208. let SEC = (deg / 15 - HRS - MIN / 60) * 3600;
  209. SEC = Math.floor(SEC * 1000) / 1000.;
  210. return HRS + sep + MIN + sep + SEC.toFixed(3);
  211. };
  212. /**
  213. * Converts a H:M:S value into decimal degrees
  214. * @param {*} value
  215. * @returns
  216. */
  217. var HMS2DecDeg = function(value){
  218. const parts = value.split(":");
  219. if(parts.length !== 3){
  220. throw("Invalid format for H:M:S value");
  221. }else{
  222. const a = parseInt(parts[0]);
  223. const b = parseFloat(parts[1])*(1/60);
  224. const c = parseFloat(parts[2]) * (1/3600);
  225. return (a + b + c)*15;
  226. }
  227. };
  228. /*
  229. ** Converts a decimal number expected to represent an angle in degree
  230. ** into a string expressing a declination ( D:M:S)
  231. */
  232. var DecDeg2DMS = function(deg, sep = ':') {
  233. var sign = deg < 0 ? '-' : '+';
  234. deg = Math.abs(deg);
  235. var DEG = Math.floor(deg);
  236. var MIN = Math.floor((deg - DEG) * 60);
  237. var SEC = (deg - DEG - MIN / 60) * 3600;
  238. SEC = Math.floor(SEC * 1000.) / 1000.;
  239. if (SEC < 0.) SEC = 0.;
  240. if (SEC > 60) SEC = 60.;
  241. return (sign + DEG + sep + MIN + sep + SEC.toFixed(3));
  242. };
  243. /**
  244. * Converts a declination D:M:S into decimal degrees
  245. * @param {*} value
  246. * @returns result in degrees
  247. */
  248. var DMS2DecDeg = function(value, sep=":"){
  249. let sign = 1;
  250. if(value[0] == "-"){
  251. sign = -1;
  252. }
  253. const parts = value.split(sep);
  254. if(parts.length !== 3){
  255. throw("Invalid format for D:M:S value");
  256. }else{
  257. const a = parseFloat(parts[0]);
  258. const b = parseFloat(parts[1]) * (1/60);
  259. const c = parseFloat(parts[2]) * (1/3600);
  260. return (a + b + c)*sign;
  261. }
  262. };
  263. /*
  264. ** A class to convert pixels into a string expressing a right ascension.
  265. **
  266. ** The constructor establishes the transformation pixels -> HMS
  267. ** with the given parameter ra0pix, ra1pix ( interval in pixels )
  268. ** and ra0, ra1 ( the same interval in decimal degrees)
  269. */
  270. class RaLabelFormatter {
  271. static enter(what) {
  272. console.group(this.name + "." + what);
  273. }
  274. static exit() {
  275. console.groupEnd();
  276. }
  277. // calculer les vraies coordonnées dans le bon système
  278. // (sans interpolation linéaire)
  279. constructor(ra0pix, ra1pix, ra0, ra1) {
  280. RaLabelFormatter.enter(this.constructor.name);
  281. this.ra0pix = ra0pix;
  282. this.ra1pix = ra1pix;
  283. this.ra0 = ra0;
  284. this.ra1 = ra1;
  285. this.slope = ((this.ra1 - this.ra0) / (this.ra1pix - this.ra0pix));
  286. this.format = this.format.bind(this);
  287. RaLabelFormatter.exit();
  288. }
  289. /*
  290. ** Returns the string representation of a RA in HMS given its input value in pixels.
  291. */
  292. format(rapix) {
  293. //RaLabelFormatter.enter(this.format.name);
  294. var res = this.ra0 + (rapix - this.ra0pix) * this.slope;
  295. //RaLabelFormatter.exit();
  296. return DecDeg2HMS(res);
  297. }
  298. };
  299. /*
  300. ** A class to convert pixels into a string expressing a declination.
  301. **
  302. ** The constructor establishes the transformation pixels -> DMS
  303. ** with the given parameter dec0pix, dec1pix ( interval in pixels )
  304. ** and dec0, dec1 ( the same interval in decimal degrees)
  305. */
  306. class DecLabelFormatter {
  307. static enter(what) {
  308. console.group(this.name + "." + what);
  309. }
  310. static exit() {
  311. console.groupEnd();
  312. }
  313. // calculer les vraies coordonnées dans le bon système
  314. // (sans interpolation linéaire)
  315. constructor(dec0pix, dec1pix, dec0, dec1) {
  316. DecLabelFormatter.enter(this.constructor.name);
  317. this.dec0pix = dec0pix;
  318. this.dec1pix = dec1pix;
  319. this.dec0 = dec0;
  320. this.dec1 = dec1;
  321. this.slope = ((this.dec1 - this.dec0) / (this.dec1pix - this.dec0pix));
  322. this.format = this.format.bind(this);
  323. DecLabelFormatter.exit();
  324. }
  325. format(decpix) {
  326. //DecLabelFormatter.enter(this.format.name);
  327. var res = this.dec0 + (decpix - this.dec0pix) * this.slope;
  328. //DecLabelFormatter.exit();
  329. return DecDeg2DMS(res);
  330. }
  331. };
  332. /*
  333. ** A function which returns the units of a spectrum resulting
  334. ** from the summation of the pixels values on each plane of a range of RA-DEC planes in a FITS cube.
  335. */
  336. /*
  337. function summedPixelsSpectrumUnit(unit) {
  338. switch (unit) {
  339. case "Jy/beam":
  340. return "Jy";
  341. break;
  342. case "erg/s/cm^2/A/arcsec^2":
  343. return "erg/s/cm^2/A";
  344. break;
  345. default:
  346. return "";
  347. }
  348. }
  349. */
  350. /*
  351. ** A function which returns the units of a 2D array resulting from
  352. ** the summation of a range of RA-DEC planes in a FITS cube.
  353. */
  354. function summedPixelsUnit(unit) {
  355. switch (unit) {
  356. case "Jy/beam":
  357. return "Jy/beam * km/s";
  358. case "erg/s/cm^2/A/arcsec^2":
  359. return "erg/s/cm^2/arcsec^2";
  360. case "K (Ta*)":
  361. return "K.km/s";
  362. default:
  363. return "";
  364. }
  365. }
  366. /*
  367. ** A function which returns a factor
  368. ** for the display of physical quantity
  369. ** The returned values are based on experience rather
  370. ** than on a purely rational approach
  371. */
  372. function unitRescale(unit) {
  373. switch (unit) {
  374. case "K (Ta*)":
  375. return 1.0;
  376. case "Jy/beam":
  377. return 1.0;
  378. case "erg/s/cm^2/A/arcsec^2":
  379. // return 1e18;
  380. return 1.;
  381. case "erg/s/cm^2/A":
  382. // return 1e12;
  383. return 1.;
  384. default:
  385. return 1.0;
  386. }
  387. }
  388. /*
  389. ** A function which sums the values of a array
  390. ** between two indices i0 (included ) and i1 ( excluded )
  391. ** and returns the sum multiplied by a coefficient coeff.
  392. */
  393. function sumArr(arr, i0, i1, coeff) {
  394. console.trace();
  395. console.log(arr);
  396. i0 = Math.max(0, i0);
  397. i1 = Math.min(arr.length - 1, i1);
  398. console.log(i0 + " " + i1);
  399. console.log(arr.slice(i0, i1 + 1))
  400. if (i0 > i1)[i0, i1] = [i1, i0];
  401. try{
  402. return coeff * arr.slice(i0, i1 + 1).reduceRight(function(a, b) { return a + b; });
  403. }catch(exception){
  404. if(arr.slice(i0, i1 + 1).length === 0)
  405. alert(`Selected interval [${i0}, ${i1+1}] is out of bound`);
  406. else
  407. alert(exception);
  408. }
  409. }
  410. /**
  411. * Utility.
  412. * A function which parses a string into an array of floats. The string is expected
  413. * to be a comma separated list of textual representation of decimal numbers.
  414. * A range [min, max[ can be provided, then the values are considered valif if and only if they lie in that range.
  415. *
  416. * @param {string} s a comma separated list of textual numbers representations
  417. * @param {number[2]} range if provided values are checked to lie in the range
  418. *
  419. * @returns {number[]|undefined} an array of float numbers or undefined.
  420. */
  421. function str2FloatArray(s, range = false) {
  422. let x = s.split(",");
  423. let w = undefined;
  424. let result = undefined;
  425. let y = x.map(function(z) { return parseFloat(z) });
  426. if (range) {
  427. w = y.map(function(t) { return (!isNaN(t) && (range[0] <= t) && (t < range[1])) });
  428. } else {
  429. w = y.map(function(t) { return true; });
  430. }
  431. if (w.reduce(function(accum, u) { return accum && u }, true)) {
  432. result = y;
  433. }
  434. return result;
  435. }
  436. /*
  437. ** A function which creates a document fragment out of an HTML string and appends it to the content of an existing element.
  438. ** The HTML string is assumed to describe a single element ( e.g. one signle div, p, etc. ).
  439. ** Returns the created element.
  440. */
  441. function createAndAppendFromHTML(html, element) {
  442. var template = document.createElement('template');
  443. template.innerHTML = html.trim();
  444. $(element).append(template.content.cloneNode(true));
  445. return element.lastChild;
  446. }
  447. function redshift2Velocity(z) {
  448. // SPEED_OF_LIGHT in m/s
  449. return z * (SPEED_OF_LIGHT / 1000);
  450. }
  451. function velocity2Redshift(v) {
  452. // SPEED_OF_LIGHT in m/s
  453. return v / (SPEED_OF_LIGHT / 1000);
  454. }
  455. /*
  456. ** Two functions to log when a function is entered and exited
  457. */
  458. function ENTER() {
  459. var caller = ENTER.caller;
  460. if (caller == null) {
  461. result = "_TOP_";
  462. } else {
  463. result = caller.name + ": entering";
  464. }
  465. console.log(result + ": entering");
  466. }
  467. function EXIT() {
  468. var caller = EXIT.caller;
  469. if (caller == null) {
  470. result = "_TOP_";
  471. } else {
  472. result = caller.name + ": exiting";
  473. }
  474. console.log(result + ": exiting");
  475. }
  476. function inRange(x, xmin, xmax) {
  477. return ((x - xmin) * (x - xmax) <= 0);
  478. }
  479. /*
  480. ** Frequency <-> Velocity derivations.
  481. **
  482. ** From https://www.iram.fr/IRAMFR/ARN/may95/node4.html
  483. */
  484. /*
  485. ** No verification is done on the values of restfreq and frequency. Both are expected to have realistic values.
  486. ** frequency and restfreq are expected to by in the same unit (i.e. both in HZ or both in GHZ)
  487. ** The result is in m/s.
  488. var f2v = function (frequency, restfreq, crval3) {
  489. return (SPEED_OF_LIGHT * (restfreq - frequency) / restfreq) + crval3;
  490. }*/
  491. var f2v = function(frequency, restfreq, vcenter) {
  492. return (SPEED_OF_LIGHT * (restfreq - frequency) / restfreq) + vcenter;
  493. }
  494. /*
  495. ** No verification is done on the values of restfreq and velocity. Both are expected to have realistic values.
  496. */
  497. var v2f = function(velocity, restfreq, vcenter) {
  498. return restfreq * (1 - (velocity - vcenter) / SPEED_OF_LIGHT)
  499. }
  500. /*
  501. ** Frequency to wavelength
  502. */
  503. var f2lambda = function(frequency) {
  504. return SPEED_OF_LIGHT / frequency;
  505. }
  506. /*
  507. ** Revert 1D array.
  508. */
  509. var revertArray = function(a) {
  510. var result = [];
  511. for (let i = 0; i < a.length; i++) {
  512. result.push(a[a.length - i - 1]);
  513. }
  514. return result;
  515. }
  516. /*
  517. ** Round *original* number to *round* numbers after 0.
  518. */
  519. var round = function(original, round) {
  520. var i = 0;
  521. var r = 1;
  522. while (i < round) {
  523. ++i;
  524. r *= 10;
  525. }
  526. return Math.round(original * r) / r;
  527. };
  528. /*
  529. ** Coordinate tabulators
  530. **
  531. ** - crval : value at reference point
  532. ** - cdelt : increment of abscissa
  533. ** - crpix : coordinate of reference point
  534. ** - n : tabulate at point of coordinate n
  535. */
  536. var linearTabulator = function(crval, cdelt, crpix, n) {
  537. return crval + (n - crpix) * cdelt;
  538. }
  539. /**
  540. * Generates a random string
  541. * (from https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript)
  542. * @param {*} s
  543. * @returns
  544. */
  545. var hashCode = function(s) {
  546. return s.split("").reduce(function(a, b) { a = ((a << 5) - a) + b.charCodeAt(0); return a & a }, 0);
  547. }
  548. var degToArcsec = function(deg) {
  549. return deg * 3600;
  550. }
  551. function degToRad(deg) {
  552. return deg * (Math.PI / 180);
  553. }
  554. /**
  555. * get the rest value for a frequency according to a redshift or a velocity
  556. * returns a deep-copy of the array with shifted line values
  557. * @param {*} frequency
  558. * @param {*} value value used to calculate shift
  559. * @param {*} type redshift or velocity
  560. */
  561. function unshift(frequency, value, type) {
  562. let result = null;
  563. if (type == REDSHIFT_SHIFT_TYPE) {
  564. result = frequency * (1 + value);
  565. } else if (type == VELOCITY_SHIFT_TYPE) {
  566. result = frequency * (1 + (value / (SPEED_OF_LIGHT / 10 ** 3)));
  567. } else {
  568. result = frequency;
  569. }
  570. return result;
  571. }
  572. /**
  573. * calculate the shifted value of all the lines in the given array
  574. * returns a deep-copy of the array with shifted line values
  575. * @param {*} lines array of lines
  576. * @param {*} value value used to calculate shift
  577. * @param {*} type redshift or velocity
  578. */
  579. function shift(frequency, value, type) {
  580. let result = null;
  581. if (type == REDSHIFT_SHIFT_TYPE) {
  582. result = frequency / (1 + value);
  583. } else if (type == VELOCITY_SHIFT_TYPE) {
  584. result = frequency / (1 + (value / (SPEED_OF_LIGHT / 10 ** 3)));;
  585. } else {
  586. alert("Unknown data type");
  587. }
  588. return result;
  589. }
  590. /**
  591. * Compute the search radius in degrees from coordinates
  592. * to get matching sources in NED
  593. *
  594. * if radius_value is FOV : Returns the max value between abs(RAmax-RAmin) and abs(Decmax-Decmin)
  595. * else : return radius_value
  596. *
  597. * radius_value : radius in arcmin or "fov"
  598. * fits_header : FITS_HEADER object
  599. */
  600. function getRadiusInDegrees(radius_value, fits_header) {
  601. if (radius_value === "fov") {
  602. // compute dec min and max in degrees
  603. let pix2dec = new PixelToDECConverter(fits_header.crval2, fits_header.crpix2, fits_header.cdelt2);
  604. let dec_min = pix2dec.convert(0);
  605. let dec_max = pix2dec.convert(fits_header.naxis2);
  606. //compute ra min and max in degrees
  607. let pix2ra = new PixelToRAConverter(fits_header.crval1, fits_header.crpix1, fits_header.cdelt1);
  608. let ra_min = pix2ra.convert(0, dec_min);
  609. let ra_max = pix2ra.convert(fits_header.naxis1, dec_max);
  610. // search radius
  611. let dist_in_ra = Math.abs(ra_min - ra_max);
  612. let dist_in_dec = Math.abs(ra_min - ra_max);
  613. return Math.max([dist_in_ra], dist_in_dec)
  614. } else {
  615. return radius_value;
  616. }
  617. }
  618. /**
  619. * Returns value of L'_Line in K.km/s.pc2, then Mgas is a function of L'_Line
  620. * @param {*} sline surface selected in summed pixel spectrum in Jy.km/s
  621. * @param {*} nu_obs line observed frequency in GHz
  622. * @param {*} dl distance in Mpc (from NED)
  623. * @param {*} z redshift
  624. * @returns
  625. */
  626. function getLpLine(sline, nu_obs, dl, z){
  627. return 3.25e7 * sline * (nu_obs**-2) * (dl**2) * ((1+z)**-3);
  628. }
  629. /**
  630. *Converts K in cm-1 (for energy values)
  631. * @param {*} energy_in_K
  632. *
  633. */
  634. var KToCm = function(energy_in_K){
  635. return energy_in_K * 0.695;
  636. }
  637. /**
  638. *Converts cm-1 in K (for energy values)
  639. * @param {*} energy_in_cm
  640. */
  641. var cmToK = function(energy_in_cm){
  642. return energy_in_cm / 0.695;
  643. }
  644. export {
  645. hashCode,
  646. degToRad,
  647. degToArcsec,
  648. linearTabulator,
  649. round,
  650. revertArray,
  651. /*f2lambda,*/ v2f,
  652. f2v,
  653. inRange,
  654. velocity2Redshift,
  655. redshift2Velocity,
  656. /*ENTER, EXIT, createAndAppendFromHTML, str2FloatArray,*/ sumArr,
  657. createAndAppendFromHTML,
  658. str2FloatArray,
  659. unitRescale,
  660. summedPixelsUnit,
  661. DecLabelFormatter,
  662. RaLabelFormatter,
  663. DecDeg2DMS,
  664. DecDeg2HMS,
  665. HMS2DecDeg,
  666. DMS2DecDeg,
  667. PixelToRAConverter,
  668. PixelToDECConverter,
  669. AbsToPixelConverter,
  670. PixelToAbsConverter,
  671. DECDDtoPixelConverter,
  672. RADDtoPixelConverter,
  673. getRadiusInDegrees,
  674. shift,
  675. unshift,
  676. getLpLine,
  677. KToCm,
  678. cmToK
  679. }