Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Add other SOHO sources (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarciabriseno authored Oct 5, 2022
1 parent 2d572d8 commit 70c5d8c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
12 changes: 12 additions & 0 deletions Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ class Config {
* Sources IDs that should be rendered on a plane rather than a hemisphere
*/
this.plane_sources = [4, 5, 28, 29];

/**
* Base image sizes, needed to make sure we query the correct resolution
* If a source is not specified, then the next source going down is used. For example, 9 through 19 are not listed because they all use the same source as 8.
*/
this.source_resolutions = {
0: 1024, // 0 - 7 are 1024
8: 4096, // 8 - 19 are 4096
20: 2048, // 20 - 23 are 2048
28: 512, // 28 is 512
29: 2048 // 29 is 2048
};
}

/**
Expand Down
29 changes: 11 additions & 18 deletions common/resolution_lookup.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
function _inclusive_between(value, min, max) {
return (min <= value) && (value <= max);
}
import Config from "../Configuration.js";

function _GetBaseImageResolution(source_id) {
if (_inclusive_between(source_id, 8, 19)) {
// SDO Images are between source IDs 8 to 19.
// These images are 4k in size
return 4096;
} else if (_inclusive_between(source_id, 4, 5)) {
// SOHO LASCO images are 1024x1024 in size. These IDs are 4 and 5
return 1024;
} else if (_inclusive_between(source_id, 20, 23) || (source_id == 29)) {
return 2048;
} else if (_inclusive_between(source_id, 28, 29)) {
return 512;
function _GetResolutionIndex(source_id) {
if (Config.source_resolutions.hasOwnProperty(source_id)) {
return source_id;
} else {
// By default assume 4096. This may result in bad scaling if it's not correct.
console.log("Source ID " + source_id + " not defined in resolution lookup table, please notify the developers to add it.");
return 4096;
// Get the index for the ID below this one.
return _GetResolutionIndex(source_id - 1);
}
}

function _GetBaseImageResolution(source_id) {
let idx = _GetResolutionIndex(source_id);
return Config.source_resolutions[idx];
}

/**
* Returns the appropriate Image Scale given a resolution choice and Source ID
* @param {number} resolution Resolution in pixels square.
Expand Down
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<option value="19">SDO HMI Mag</option>
<option value="4">SOHO LASCO C2</option>
<option value="5">SOHO LASCO C3</option>
<option value="0">SOHO EIT 171</option>
<option value="1">SOHO EIT 195</option>
<option value="2">SOHO EIT 284</option>
<option value="3">SOHO EIT 304</option>
<option value="7">SOHO MDI Continuum</option>
<option value="6">SOHO MDI Magnetogram</option>
<option value="20">STEREO-A EUVI-A 171</option>
<option value="21">STEREO-A EUVI-A 195</option>
<option value="22">STEREO-A EUVI-A 284</option>
Expand Down

0 comments on commit 70c5d8c

Please sign in to comment.