Add scripts

This commit is contained in:
2024-06-16 16:31:53 +02:00
parent af4be850cb
commit f8c9fec77e
6 changed files with 74 additions and 5 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
core.log("This script convert any FITS file into XISF with ZSTD compression");
if(files.length == 0) if(files.length == 0)
{ {
core.files("No files"); core.log("No input files");
throw ""; throw "";
} }
+9 -2
View File
@@ -11,10 +11,9 @@ for(file of files)
if(file.suffix() == "fits" || file.suffix() == "fit" || file.suffix() == "xisf") if(file.suffix() == "fits" || file.suffix() == "fit" || file.suffix() == "xisf")
{ {
let keywords = file.fitsKeywords(); let keywords = file.fitsKeywords();
let item = core.getItem(keywords); let item = core.getItem(keywords, "Select keyword");
core.log("You selected keyword " + item); core.log(file.fitsKeywords()); core.log("You selected keyword " + item); core.log(file.fitsKeywords());
// some sample files
core.log("fileName() " + file.fileName()); core.log("fileName() " + file.fileName());
core.log("absoluteFilePath() " + file.absoluteFilePath()); core.log("absoluteFilePath() " + file.absoluteFilePath());
core.log("absolutePath() " + file.absolutePath()); core.log("absolutePath() " + file.absolutePath());
@@ -24,6 +23,14 @@ for(file of files)
core.log("completeBase() " + file.completeBaseName()); core.log("completeBase() " + file.completeBaseName());
core.log("suffix() " + file.suffix()); core.log("suffix() " + file.suffix());
core.log("size() " + file.size()); core.log("size() " + file.size());
let stats = file.stats();
core.log("Image statistics");
core.log("\tMinimum: " + stats.min);
core.log("\tMaximum: " + stats.max);
core.log("\tMedian:" + stats.median);
core.log("\tStandard deviation:" + stats.stddev);
core.log("\tMedian Absolute Deviation:" + stats.mad);
break; break;
} }
} }
+8
View File
@@ -0,0 +1,8 @@
for(file of files)
{
if(file.suffix() == "fits" || file.suffix() == "fit" || file.suffix() == "xisf")
{
let stats = file.stats();
core.log("File: \"" + file.fileName() + "\" - median: " + stats.median);
}
}
+50
View File
@@ -0,0 +1,50 @@
function checkFITS(key)
{
const noEditableKey = ["SIMPLE", "BITPIX", "NAXIS", "NAXIS1", "NAXIS2", "NAXIS3", "EXTEND", "BZERO", "BSCALE"];
return noEditableKey.indexOf(key) < 0;
}
if(files.length == 0)
{
core.log("No input files");
throw "";
}
let action = core.getItem(["UPDATE", "ADD", "REMOVE"], "Do you want update, add or remove record?");
let modify = new FITSRecordModify();
if(action == "UPDATE")
{
let keywords = files[0].fitsKeywords().filter(checkFITS);
let keyword = core.getItem(keywords, "Select keyword to update");
let value = files[0].fitsValue(keyword);
if(isNaN(value))
value = core.getString("Enter new value", value);
else
value = core.getFloat("Enter new value", value);
modify.updateKeyword(keyword, value);
}
else if(action == "ADD")
{
let keyword = core.getString("Enter keyword to add");
let value = core.getString("Enter new value");
keyword = keyword.toUpperCase();
modify.addKeyword(keyword, value);
}
else if(action == "REMOVE")
{
let keywords = files[0].fitsKeywords().filter(checkFITS);
let keyword = core.getItem(keywords, "Select keyword to remove");
modify.removeKeyword(keyword);
}
for(file of files)
{
if(file.suffix() == "fits" || file.suffix() == "fit" || file.suffix() == "xisf")
{
core.log("Modifing " + file.fileName());
file.modifyFITSRecords(modify);
}
}
+2
View File
@@ -2,5 +2,7 @@
<qresource prefix="/scripts"> <qresource prefix="/scripts">
<file>example script</file> <file>example script</file>
<file>convert to XISF</file> <file>convert to XISF</file>
<file>median</file>
<file>modify FITS header</file>
</qresource> </qresource>
</RCC> </RCC>
+1 -1
View File
@@ -57,7 +57,7 @@
</screenshots> </screenshots>
<content_rating type="oars-1.1"/> <content_rating type="oars-1.1"/>
<releases> <releases>
<release version="20240610" date="2024-06-10"> <release version="20240616" date="2024-06-16">
<description> <description>
<ul> <ul>
<li>Batch processing with JavaScript</li> <li>Batch processing with JavaScript</li>