Skip to content

Commit

Permalink
The segments of FengYun (HDF files) are normally in Eumetcast gzipped.
Browse files Browse the repository at this point in the history
EUMETCastView can now process HDF files that are decompressed.
Change in mainwindow for saveState and saveGeometry.
  • Loading branch information
hvanruys committed Feb 8, 2018
1 parent f3e94bc commit edc85bd
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 116 deletions.
66 changes: 46 additions & 20 deletions core/formgeostationary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,9 +1114,12 @@ void FormGeostationary::CreateGeoImageHDF(SegmentListGeostationary *sl, QString

QString filetiming;
QString filedate;
QStringList llVIS_IRgz;
QStringList llHRVgz;
QStringList llVIS_IR;
QStringList llHRV;
QString filepattern;
QString filepatterngz;

eGeoSatellite whichgeo = sl->getGeoSatellite();
int geoindex = sl->getGeoSatelliteIndex();
Expand All @@ -1141,43 +1144,66 @@ void FormGeostationary::CreateGeoImageHDF(SegmentListGeostationary *sl, QString


if(whichgeo == eGeoSatellite::FY2E && (type == "VIS_IR" || type == "VIS_IR Color"))
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2E_FDI_???") + QString("_001_NOM.HDF.gz");
{
filepatterngz = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2E_FDI_???") + QString("_001_NOM.HDF.gz");
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2E_FDI_???") + QString("_001_NOM.HDF");
}
else if(whichgeo == eGeoSatellite::FY2G && (type == "VIS_IR" || type == "VIS_IR Color"))
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2G_FDI_???") + QString("_001_NOM.HDF.gz");
{
filepatterngz = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2G_FDI_???") + QString("_001_NOM.HDF.gz");
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2G_FDI_???") + QString("_001_NOM.HDF");
}
else if(whichgeo == eGeoSatellite::FY2E && type == "HRV")
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2E_FDI_VIS1KM") + QString("_001_NOM.HDF.gz");
{
filepatterngz = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2E_FDI_VIS1KM") + QString("_001_NOM.HDF.gz");
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2E_FDI_VIS1KM") + QString("_001_NOM.HDF");
}
else if(whichgeo == eGeoSatellite::FY2G && type == "HRV")
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2G_FDI_VIS1KM") + QString("_001_NOM.HDF.gz");

{
filepatterngz = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2G_FDI_VIS1KM") + QString("_001_NOM.HDF.gz");
filepattern = QString("Z_SATE_C_BABJ_") + filetiming + QString("_O_FY2G_FDI_VIS1KM") + QString("_001_NOM.HDF");
}

if(type == "VIS_IR" || type == "VIS_IR Color")
{
llVIS_IR = this->getGeostationarySegments(geoindex, "VIS_IR", sl->getImagePath(), spectrumvector, filepattern);
qDebug() << QString("llVIS_IR count = %1").arg(llVIS_IR.count());
for (int j = 0; j < llVIS_IR.size(); ++j)
llVIS_IRgz = this->getGeostationarySegments(geoindex, "VIS_IR", sl->getImagePath(), spectrumvector, filepatterngz);
qDebug() << QString("llVIS_IR count = %1").arg(llVIS_IRgz.count());
for (int j = 0; j < llVIS_IRgz.size(); ++j)
{
qDebug() << QString("llVIS_IR at %1 = %2 spectrumvector = %3").arg(j).arg(llVIS_IR.at(j)).arg(spectrumvector.at(j));
qDebug() << QString("llVIS_IR at %1 = %2 spectrumvector = %3").arg(j).arg(llVIS_IRgz.at(j)).arg(spectrumvector.at(j));
}
if(llVIS_IR.count() == 0)
if(llVIS_IRgz.count() == 0)
{
QApplication::restoreOverrideCursor();
emit enabletoolboxbuttons(true);
return;
llVIS_IR = this->getGeostationarySegments(geoindex, "VIS_IR", sl->getImagePath(), spectrumvector, filepattern);
if(llVIS_IR.count() == 0)
{
QApplication::restoreOverrideCursor();
emit enabletoolboxbuttons(true);
return;
}
else
sl->ComposeImageHDFInThread(llVIS_IR, spectrumvector, inversevector);
}
else
sl->ComposeImageHDFInThread(llVIS_IR, spectrumvector, inversevector);
sl->ComposeImageHDFInThread(llVIS_IRgz, spectrumvector, inversevector);
}
else if(type == "HRV")
{
llHRV = this->getGeostationarySegments(geoindex, "HRV", sl->getImagePath(), spectrumvector, filepattern);
if(llHRV.count() == 0)
llHRVgz = this->getGeostationarySegments(geoindex, "HRV", sl->getImagePath(), spectrumvector, filepatterngz);
if(llHRVgz.count() == 0)
{
QApplication::restoreOverrideCursor();
emit enabletoolboxbuttons(true);
return;
llHRV = this->getGeostationarySegments(geoindex, "HRV", sl->getImagePath(), spectrumvector, filepattern);
if(llHRV.count() == 0)
{
QApplication::restoreOverrideCursor();
emit enabletoolboxbuttons(true);
return;
}
else
sl->ComposeImageHDFInThread(llHRV, spectrumvector, inversevector);
}
else
sl->ComposeImageHDFInThread(llHRV, spectrumvector, inversevector);
sl->ComposeImageHDFInThread(llHRVgz, spectrumvector, inversevector);
}

}
Expand Down
9 changes: 5 additions & 4 deletions core/globe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ void Globe::dumpOpenGLdiagnostics()

Globe::~Globe()
{
// if(futureRender3DGeo.isRunning())
// futureRender3DGeo.cancel();

delete imageptrs->pmOriginal;
qDebug() << "closing Globe";

Expand Down Expand Up @@ -1430,12 +1433,10 @@ void Globe::Render3DGeoSegment(int geoindex)

qDebug() << "Globe::Render3DGeoSegment(SegmentListMeteosat::eGeoSatellite sat)";

// g_mutex.lock();

for (int i = 0; i < imageptrs->ptrimageGeostationary->height(); i=i+1)
{
Render3DGeoSegmentLine( i, geoindex);

// g_mutex.unlock();
}

qDebug() << "Globe::Render3DGeoSegment(SegmentListMeteosat::eGeoSatellite sat)";

Expand Down
77 changes: 6 additions & 71 deletions core/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ MainWindow::MainWindow(QWidget *parent) :
{
ui->setupUi(this);


setupStatusBar();

satlist = new SatelliteList();
Expand Down Expand Up @@ -189,7 +190,8 @@ MainWindow::MainWindow(QWidget *parent) :

qDebug() << QString("HDF5 library %1.%2.%3").arg(majnum).arg(minnum).arg(relnum);

loadLayout();
restoreGeometry(opts.mainwindowgeometry);
restoreState(opts.mainwindowstate);

seglist->ReadXMLfiles();

Expand All @@ -198,8 +200,6 @@ MainWindow::MainWindow(QWidget *parent) :
arg(QThreadPool::globalInstance()->maxThreadCount()).
arg(QThreadPool::globalInstance()->activeThreadCount());



qDebug() << "currentthreadid = " << QThread::currentThreadId();
QList<QThread*> mainwindowthreadslist = this->findChildren <QThread*> ();
for(int i = 0; i < mainwindowthreadslist.count(); i++)
Expand Down Expand Up @@ -268,6 +268,7 @@ void MainWindow::createDockWidget()
//dockwidget->setw ->setMinimumWidth(480);
//dockwidget->close();
addDockWidget(Qt::LeftDockWidgetArea,dockwidget);
formtoolbox->resize(200, formtoolbox->height());
}

void MainWindow::timerDone(void)
Expand All @@ -290,12 +291,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
{
qDebug() << "in MainWindow::closeEvent(QCloseEvent *event)";

//opts.mainwindowgeometry = saveGeometry();
//opts.windowstate = saveState(0);
opts.mainwindowgeometry = saveGeometry();
opts.mainwindowstate = saveState(0);
forminfrascales->close();
saveLayout();



delete timer;
delete formtoolbox;
Expand Down Expand Up @@ -671,67 +669,4 @@ void MainWindow::updateWindowTitle()
this->setWindowTitle(windowTitleFormat);
}

void MainWindow::saveLayout()
{
QString fileName = "Layout.bin";
QFile file(fileName);
if (!file.open(QFile::WriteOnly)) {
QString msg = tr("Failed to open %1\n%2")
.arg(fileName)
.arg(file.errorString());
QMessageBox::warning(this, tr("Error"), msg);
return;
}

QByteArray geo_data = saveGeometry();
QByteArray layout_data = saveState();

bool ok = file.putChar((uchar)geo_data.size());
if (ok)
ok = file.write(geo_data) == geo_data.size();
if (ok)
ok = file.write(layout_data) == layout_data.size();

if (!ok) {
QString msg = tr("Error writing to %1\n%2")
.arg(fileName)
.arg(file.errorString());
QMessageBox::warning(this, tr("Error"), msg);
return;
}
}

void MainWindow::loadLayout()
{
QString fileName = "Layout.bin";
QFile file(fileName);
if (!file.open(QFile::ReadOnly))
return;


uchar geo_size;
QByteArray geo_data;
QByteArray layout_data;

bool ok = file.getChar((char*)&geo_size);
if (ok) {
geo_data = file.read(geo_size);
ok = geo_data.size() == geo_size;
}
if (ok) {
layout_data = file.readAll();
ok = layout_data.size() > 0;
}

if (ok)
ok = restoreGeometry(geo_data);
if (ok)
ok = restoreState(layout_data);

// if (!ok) {
// QString msg = tr("Error reading %1")
// .arg(fileName);
// QMessageBox::warning(this, tr("Error"), msg);
// return;
// }
}
2 changes: 0 additions & 2 deletions core/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class MainWindow : public QMainWindow
void setupStatusBar();
void createDockWidget();
void closeEvent(QCloseEvent *event);
void loadLayout();
void saveLayout();

Ui::MainWindow *ui;

Expand Down
13 changes: 10 additions & 3 deletions core/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ void Options::Initialize()
gshhsglobe2On = settings.value("/window/gshhsglobe2on", true ).toBool();
gshhsglobe3On = settings.value("/window/gshhsglobe3on", false ).toBool();
graytextureOn = settings.value("/window/graytextureon", false ).toBool();
ephemsplittersizes = settings.value("/ephemwindow/splitterSizes").toByteArray(); // .value<QByteArray>();

zoomfactoravhrr = settings.value("/window/zoomfactoravhrr", 100).toInt();
if( zoomfactoravhrr < 5 || zoomfactoravhrr > 500 )
Expand Down Expand Up @@ -251,6 +250,11 @@ void Options::Initialize()
downloadxmlslstr = settings.value("/datahub/downloadxmlslstr", true).toBool();
xmllogging = false;

ephemsplittersizes = settings.value("/ephemwindow/splitterSizes").toByteArray();

mainwindowgeometry = settings.value("/window/mainwindowgeometry").toByteArray();
mainwindowstate = settings.value("/window/mainwindowstate").toByteArray();

CreateGeoSatelliteIni();

}
Expand Down Expand Up @@ -439,8 +443,6 @@ void Options::Save()
settings.setValue("/window/udpmessages", udpmessages );


settings.setValue("/ephemwindow/splitterSizes", ephemsplittersizes );

settings.setValue("/window/zoomfactoravhrr", zoomfactoravhrr );
settings.setValue("/window/zoomfactormeteosat", zoomfactormeteosat );
settings.setValue("/window/zoomfactorprojection", zoomfactorprojection );
Expand Down Expand Up @@ -515,6 +517,11 @@ void Options::Save()
settings.setValue("/datahub/downloadxmlolciefr", downloadxmlolciefr);
settings.setValue("/datahub/downloadxmlolcierr", downloadxmlolcierr);
settings.setValue("/datahub/downloadxmlslstr", downloadxmlslstr);

settings.setValue("/ephemwindow/splitterSizes", ephemsplittersizes );
settings.setValue("/window/mainwindowgeometry", mainwindowgeometry);
settings.setValue("/window/mainwindowstate", mainwindowstate);

}

void Options::CreateGeoSatelliteIni()
Expand Down
2 changes: 2 additions & 0 deletions core/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class Options
int dnbspbwindowsvalue;

QByteArray ephemsplittersizes;
QByteArray mainwindowgeometry;
QByteArray mainwindowstate;

QString localdirremote;
QString dirremote;
Expand Down
50 changes: 34 additions & 16 deletions core/segmentlistgeostationary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,29 +1126,47 @@ void SegmentListGeostationary::ComposeSegmentImageHDFInThread(QStringList fileli
int r,g, b;

QImage *im;
QStringList outfilename;
QStringList strlistout;
QString inFileName;
QString outFileName;

im = imageptrs->ptrimageGeostationary;


for(int j = 0; j < filelist.size(); j++)
{
QFile inFile(this->getImagePath() + "/" + filelist.at(j));
inFile.open(QIODevice::ReadOnly);
QByteArray compressed = inFile.readAll();
QString teststring = filelist.at(j).mid(filelist.at(j).length()-3);
inFileName = this->getImagePath() + "/" + filelist.at(j);
outFileName = filelist.at(j);

QByteArray decompressed;
outfilename.append(filelist.at(j).mid(0, filelist.at(j).length()-3));
if(teststring == ".gz" || teststring == ".GZ") // compressed HDF
{

QFile outfile(filelist.at(j).mid(0, filelist.at(j).length()-3));
if(QCompressor::gzipDecompress(compressed, decompressed))
QFile inFile(inFileName);
inFile.open(QIODevice::ReadOnly);
QByteArray compressed = inFile.readAll();

QByteArray decompressed;
strlistout.append(filelist.at(j).mid(0, filelist.at(j).length()-3));
QFile outFile(filelist.at(j).mid(0, filelist.at(j).length()-3));

if(QCompressor::gzipDecompress(compressed, decompressed))
{
outFile.open(QIODevice::WriteOnly);
QDataStream out(&outFile);
out.writeRawData(decompressed.constData(), decompressed.length());
qDebug() << "writing decompressed file " << strlistout.at(j);
}
else
qDebug() << "-----> gzipDecompress failed !";
}
else // already decompressed HDF
{
outfile.open(QIODevice::WriteOnly);
QDataStream out(&outfile);
out.writeRawData(decompressed.constData(), decompressed.length());
qDebug() << "writing decompressed file " << outfilename.at(j);
strlistout.append(filelist.at(j));

QFile::copy(inFileName, outFileName);
}
else
qDebug() << "-----> gzipDecompress failed !";


}

Expand Down Expand Up @@ -1188,8 +1206,8 @@ void SegmentListGeostationary::ComposeSegmentImageHDFInThread(QStringList fileli
for(int j = 0; j < filelist.size(); j++)
{

if( (h5_file_id[j] = H5Fopen(outfilename.at(j).toLatin1(), H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
qDebug() << "File " << outfilename.at(j) << " not open !!";
if( (h5_file_id[j] = H5Fopen(strlistout.at(j).toLatin1(), H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
qDebug() << "File " << strlistout.at(j) << " not open !!";


if( (nomfileinfo_id[j] = H5Dopen2(h5_file_id[j], "/NomFileInfo", H5P_DEFAULT)) < 0)
Expand Down

0 comments on commit edc85bd

Please sign in to comment.