magao-x / MagAOX

The MagAO-X Software System

Home Page:https://magao-x.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

seeing corrections inconsistent

jaredmales opened this issue · comments

tcsi mag1_fwhm_corr matches what is plotted. dimm_fwhm matches what is plotted, not _corr. similarly, the web ui presents the numbers that match the plot.

is the dimm corrected on the plot / in the data stream that get seeting is using?

Recording my investigation here:

Inspecting http://weather.lco.cl/clima/weather/Magellan/JS/seeingCalPlotFunc.js shows the fetching and pre-processing. The mapping of sources to numbers is here:

// initial data PHP script
seeingPlot.initialphp1 = "PHP/grabCalMag1.php";
seeingPlot.initialphp2 = "PHP/grabCalMag2.php";
seeingPlot.initialphp3 = "PHP/grabCalDimm.php";

After fetching from those endpoints, we have on line 143:

// main drawing function. Gets the data, parses and draws all
// plot elements.
seeingPlot.initialData = function () {
	d3.json(seeingPlot.initialphp1, function(error1, data1) {
		// after getting the data it's parsed into array
		data1.forEach(function(d){
			d.tm = seeingPlot.parseDate(d.tm);
			d.el = 1.0/Math.cos((90-d.el)*Math.PI/180.0);
			d.fw = d.fw / Math.pow(d.el, 0.6); // treating elevation as airmass!
			seeingPlot.jsondata1.push(d);
		})

	
	d3.json(seeingPlot.initialphp2, function(error2, data2) {
		// after getting the data it's parsed into array
		data2.forEach(function(d){
			d.tm = seeingPlot.parseDate(d.tm);
			d.el = 1.0/Math.cos((90-d.el)*Math.PI/180.0);
			d.fw = d.fw / Math.pow(d.el, 0.6);
			seeingPlot.jsondata2.push(d);
		})
		
	d3.json(seeingPlot.initialphp3, function(error3, data3) {
	 // after getting the data it's parsed into array
	 data3.forEach(function(d){
	 	d.tm = seeingPlot.parseDate(d.tm);
	 	d.el = 1.0/Math.cos((90-d.el)*Math.PI/180.0);
	 	//d.fw = d.fw / Math.pow(d.el, 0.6); //if its not unscaled
	 	d.fw = +d.fw;
	 	seeingPlot.jsondata3.push(d);
	 })
// ... rest omitted ...

If Apache is to be believed, this file is unchanged since Dec 29 2015, so I don't think the formulae have changed in recent memory.

To summarize:

  • To get the value used in the plot, a scaling is applied to the fw elements for mag1 and mag2 data but the dimm fw data is used as-is
  • The elevation in degrees is returned in el, which is then used to compute zenith angle (90-d.el), converted to radians (*Math.PI/180.0), and used to compute the secant (1/Math.cos(...)). So, after that conversion, d.el is sec(z).
  • The scaling of the fwhm returned by the PHP script for mag1 and mag2 is by airmass^(-3/5)
  • The fwhm returned by the PHP script for the dimm is used as-is, presumably because it has already been corrected to sec(z)=1

MagAO-X automates collection of seeing information by launching a short Python script at regular intervals.

This script hits the PHP script endpoints to retrieve recent/current seeing measurements and writes them to files in /tmp.

$ cat /tmp/*.tsv
datetime fwhm elevation
2023-05-25 00:25:21 0.68 52.84
datetime fwhm elevation
2023-05-25 00:25:05 0.9 52.48
datetime fwhm elevation
2023-05-25 00:25:05 0.81 35.02

$ ls /tmp/*.tsv
/tmp/dimm.tsv  /tmp/mag1.tsv  /tmp/mag2.tsv

This script gets called by tcsi (the TCS interface app/device):

int rv = system("query_seeing > /dev/null");

not more often than

int m_seeingInterval {2};

The formulae are applied to mag1:

m_mag1_fwhm_corr = m_mag1_fwhm * pow(cos( (90.-m_mag1_el)*3.14159/180.), 3./5.);

mag2:

m_mag2_fwhm_corr = m_mag2_fwhm * pow(cos( (90.-m_mag2_el)*3.14159/180.), 3./5.);

and, it appears, erroneously, to dimm:

m_dimm_fwhm_corr = m_dimm_fwhm * pow(cos( (90.-m_dimm_el)*3.14159/180.), 3./5.);

The takeaway is that we should ignore the dimm_fwhm_corr element in historical data because it's been double-corrected