Add sky temperature calculation. Add Solar flux plot. Add .gitattributes so .fits files are treated as binary.chirpmodem-v8.0.0
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 641 KiB |
|
After Width: | Height: | Size: 682 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 341 KiB |
|
After Width: | Height: | Size: 393 KiB |
|
After Width: | Height: | Size: 367 B |
@ -0,0 +1,149 @@
@@ -0,0 +1,149 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <algorithm> |
||||
|
||||
#include <QRegExp> |
||||
#include <QDebug> |
||||
#include <QResource> |
||||
|
||||
#include "fits.h" |
||||
|
||||
FITS::FITS(QString resourceName) : |
||||
m_valid(false) |
||||
{ |
||||
QResource m_res(resourceName); |
||||
int m_headerSize = 2880; |
||||
m_data = m_res.uncompressedData(); |
||||
int hLen = std::min((qint64)m_headerSize * 3, m_res.uncompressedSize()); // Could possibly be bigger
|
||||
QByteArray headerBytes = m_data.left(hLen); |
||||
QString header = QString::fromLatin1(headerBytes); |
||||
QRegExp widthRE("NAXIS1 *= *([0-9]+)"); |
||||
QRegExp heightRE("NAXIS2 *= *([0-9]+)"); |
||||
QRegExp bitsPerPixelRE("BITPIX *= *(-?[0-9]+)"); |
||||
QRegExp bzeroRE("BZERO *= *([0-9]+)"); |
||||
QRegExp bscaleRE("BSCALE *= *(-?[0-9]+(.[0-9]+)?)"); |
||||
QRegExp buintRE("BUNIT *= *\\'([A-Z ]+)\\'"); |
||||
QRegExp cdelt1RE("CDELT1 *= *(-?[0-9]+(.[0-9]+)?)"); |
||||
QRegExp cdelt2RE("CDELT2 *= *(-?[0-9]+(.[0-9]+)?)"); |
||||
QRegExp endRE("END {77}"); |
||||
|
||||
if (widthRE.indexIn(header) != -1) |
||||
m_width = widthRE.capturedTexts()[1].toInt(); |
||||
else |
||||
{ |
||||
qWarning() << "FITS: NAXIS1 missing"; |
||||
return; |
||||
} |
||||
if (heightRE.indexIn(header) != -1) |
||||
m_height = heightRE.capturedTexts()[1].toInt(); |
||||
else |
||||
{ |
||||
qWarning() << "FITS: NAXIS2 missing"; |
||||
return; |
||||
} |
||||
if (bitsPerPixelRE.indexIn(header) != -1) |
||||
m_bitsPerPixel = bitsPerPixelRE.capturedTexts()[1].toInt(); |
||||
else |
||||
{ |
||||
qWarning() << "FITS: BITPIX missing"; |
||||
return; |
||||
} |
||||
m_bytesPerPixel = abs(m_bitsPerPixel)/8; |
||||
if (bzeroRE.indexIn(header) != -1) |
||||
m_bzero = bzeroRE.capturedTexts()[1].toInt(); |
||||
else |
||||
m_bzero = 0; |
||||
if (bscaleRE.indexIn(header) != -1) |
||||
m_bscale = bscaleRE.capturedTexts()[1].toDouble(); |
||||
else |
||||
m_bscale = 1.0; |
||||
|
||||
if (cdelt1RE.indexIn(header) != -1) |
||||
m_cdelta1 = cdelt1RE.capturedTexts()[1].toDouble(); |
||||
else |
||||
m_cdelta1 = 0.0; |
||||
if (cdelt2RE.indexIn(header) != -1) |
||||
m_cdelta2 = cdelt2RE.capturedTexts()[1].toDouble(); |
||||
else |
||||
m_cdelta2 = 0.0; |
||||
|
||||
if (buintRE.indexIn(header) != -1) |
||||
{ |
||||
m_buint = buintRE.capturedTexts()[1].trimmed(); |
||||
if (m_buint.contains("MILLI")) |
||||
m_uintScale = 0.001f; |
||||
else |
||||
m_uintScale = 1.0f; |
||||
} |
||||
else |
||||
m_uintScale = 1.0f; |
||||
int endIdx = endRE.indexIn(header); |
||||
if (endIdx == -1) |
||||
{ |
||||
qWarning() << "FITS: END missing"; |
||||
return; |
||||
} |
||||
m_dataStart = ((endIdx + m_headerSize) / m_headerSize) * m_headerSize; |
||||
m_valid = true; |
||||
} |
||||
|
||||
float FITS::value(int x, int y) |
||||
{ |
||||
int offset = m_dataStart + (m_height-1-y) * m_width * m_bytesPerPixel + x * m_bytesPerPixel; |
||||
const uchar *data = (const uchar *)m_data.data(); |
||||
// Big-endian
|
||||
int v = 0; |
||||
for (int i = m_bytesPerPixel - 1; i >= 0; i--) |
||||
v += data[offset++] << (i*8); |
||||
if (m_bitsPerPixel > 0) |
||||
{ |
||||
// Sign-extend
|
||||
switch (m_bytesPerPixel) |
||||
{ |
||||
case 1: |
||||
v = (char)v; |
||||
break; |
||||
case 2: |
||||
v = (qint16)v; |
||||
break; |
||||
case 3: |
||||
v = (qint32)v; |
||||
break; |
||||
} |
||||
return v * m_bscale + m_bzero; |
||||
} |
||||
else |
||||
return *reinterpret_cast<float*>(&v); |
||||
} |
||||
|
||||
float FITS::scaledValue(int x, int y) |
||||
{ |
||||
float v = value(x, y); |
||||
return v * m_uintScale; |
||||
} |
||||
|
||||
int FITS::mod(int a, int b) |
||||
{ |
||||
return a - b * floor(a/(double)b); |
||||
} |
||||
|
||||
float FITS::scaledWrappedValue(int x, int y) |
||||
{ |
||||
float v = value(mod(x, m_width), mod(y, m_height)); |
||||
return v * m_uintScale; |
||||
} |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_UTIL_FITS_H |
||||
#define INCLUDE_UTIL_FITS_H |
||||
|
||||
#include <QString> |
||||
#include <QByteArray> |
||||
|
||||
#include "export.h" |
||||
|
||||
// Flexible Image Transport System
|
||||
// Specification: https://fits.gsfc.nasa.gov/standard40/fits_standard40aa-le.pdf
|
||||
// This just implements the minimum functionality used by the files
|
||||
// used by the StarTracker plugin
|
||||
class SDRBASE_API FITS { |
||||
|
||||
bool m_valid; |
||||
int m_width; // In pixels
|
||||
int m_height; // In pixels
|
||||
int m_bitsPerPixel; // BITPIX=-32 means single precision floating point
|
||||
int m_bytesPerPixel; |
||||
int m_bzero; |
||||
double m_bscale; |
||||
QString m_buint; // "K TB" "MILLIK TB" "K"
|
||||
float m_uintScale; |
||||
double m_cdelta1; // How many degrees RA per horizontal pixel
|
||||
double m_cdelta2; // How many degrees Declination per vertical pixel
|
||||
|
||||
int m_dataStart; |
||||
QByteArray m_data; |
||||
|
||||
public: |
||||
|
||||
FITS(QString resourceName); |
||||
|
||||
float value(int x, int y); |
||||
float scaledValue(int x, int y); |
||||
float scaledWrappedValue(int x, int y); |
||||
|
||||
double degreesPerPixelH() { return m_cdelta1; } |
||||
double degreesPerPixelV() { return m_cdelta2; } |
||||
int width() { return m_width; } |
||||
int height() { return m_height; } |
||||
bool valid() { return m_valid; } |
||||
|
||||
protected: |
||||
|
||||
int mod(int a, int b); |
||||
}; |
||||
|
||||
#endif // INCLUDE_UTIL_FITS_H
|
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "httpdownloadmanagergui.h" |
||||
|
||||
#include <QDebug> |
||||
#include <QProgressDialog> |
||||
#include <QMessageBox> |
||||
|
||||
HttpDownloadManagerGUI::HttpDownloadManagerGUI() |
||||
{ |
||||
connect(this, &HttpDownloadManager::downloadComplete, this, &HttpDownloadManagerGUI::downloadCompleteGUI); |
||||
} |
||||
|
||||
QNetworkReply *HttpDownloadManagerGUI::download(const QUrl &url, const QString &filename, QWidget *parent) |
||||
{ |
||||
QNetworkReply *reply = HttpDownloadManager::download(url, filename); |
||||
if (parent != nullptr) |
||||
{ |
||||
QProgressDialog *progressDialog = new QProgressDialog(parent); |
||||
progressDialog->setAttribute(Qt::WA_DeleteOnClose); |
||||
progressDialog->setCancelButton(nullptr); |
||||
progressDialog->setMinimumDuration(500); |
||||
progressDialog->setLabelText(QString("Downloading %1.").arg(url.toString())); |
||||
m_progressDialogs.append(progressDialog); |
||||
connect(reply, &QNetworkReply::downloadProgress, this, [progressDialog](qint64 bytesRead, qint64 totalBytes) { |
||||
progressDialog->setMaximum(totalBytes); |
||||
progressDialog->setValue(bytesRead); |
||||
}); |
||||
} |
||||
else |
||||
m_progressDialogs.append(nullptr); |
||||
return reply; |
||||
} |
||||
|
||||
// Confirm if user wants to re-download an existing file
|
||||
bool HttpDownloadManagerGUI::confirmDownload(const QString& filename, QWidget *parent, int maxAge) |
||||
{ |
||||
qint64 age = HttpDownloadManager::fileAgeInDays(filename); |
||||
if ((age == -1) || (age > maxAge)) |
||||
return true; |
||||
else |
||||
{ |
||||
QMessageBox::StandardButton reply; |
||||
if (age == 0) |
||||
reply = QMessageBox::question(parent, "Confirm download", "This file was last downloaded today. Are you sure you wish to redownload it?", QMessageBox::Yes|QMessageBox::No); |
||||
else if (age == 1) |
||||
reply = QMessageBox::question(parent, "Confirm download", "This file was last downloaded yesterday. Are you sure you wish to redownload it?", QMessageBox::Yes|QMessageBox::No); |
||||
else |
||||
reply = QMessageBox::question(parent, "Confirm download", QString("This file was last downloaded %1 days ago. Are you sure you wish to redownload this file?").arg(age), QMessageBox::Yes|QMessageBox::No); |
||||
return reply == QMessageBox::Yes; |
||||
} |
||||
} |
||||
|
||||
void HttpDownloadManagerGUI::downloadCompleteGUI(const QString& filename, bool success) |
||||
{ |
||||
int idx = m_filenames.indexOf(filename); |
||||
if (idx >= 0) |
||||
{ |
||||
QProgressDialog *progressDialog = m_progressDialogs[idx]; |
||||
if (progressDialog != nullptr) |
||||
progressDialog->close(); |
||||
m_filenames.remove(idx); |
||||
m_progressDialogs.remove(idx); |
||||
} |
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_HTTPDOWNLOADMANAGERGUI_H |
||||
#define INCLUDE_HTTPDOWNLOADMANAGERGUI_H |
||||
|
||||
#include "util/httpdownloadmanager.h" |
||||
|
||||
#include "export.h" |
||||
|
||||
class QWidget; |
||||
class QProgressDialog; |
||||
|
||||
// Class to download files via http and write them to disk with progress dialog
|
||||
class SDRGUI_API HttpDownloadManagerGUI : public HttpDownloadManager |
||||
{ |
||||
public: |
||||
HttpDownloadManagerGUI(); |
||||
QNetworkReply *download(const QUrl &url, const QString &filename, QWidget *parent = nullptr); |
||||
|
||||
static bool confirmDownload(const QString& filename, QWidget *parent = nullptr, int maxAge = 100); |
||||
|
||||
private: |
||||
QVector<QString> m_filenames; |
||||
QVector<QProgressDialog *> m_progressDialogs; |
||||
|
||||
public slots: |
||||
void downloadCompleteGUI(const QString &filename, bool success); |
||||
}; |
||||
|
||||
#endif /* INCLUDE_HTTPDOWNLOADMANAGERGUI_H */ |
||||