Software Development > PCL and PJSR Development
PJSR: some questions (creating dir, writing FITS key)
kwiechen:
Hello,
I have two questions regarding PJSR programming:
1) Is there an OS-independent way to check if a directory exists and to create one if not?
2) Is it possible to write FITS keywords and values back when saving an ImageWindow?
Best,
Kai
Juan Conejero:
Hi Kai,
--- Quote ---1) Is there an OS-independent way to check if a directory exists and to create one if not?
--- End quote ---
These global methods of the File object provide the functionality you're looking for:
Boolean File.directoryExists( String dirPath )
void File.createDirectory( String dirPath[, Boolean createIntermediateDirs=true] )
Example:
var pathToMyDir = "/path/to/mydir";
if ( !File.directoryExists( pathToMyDir ) )
File.createDirectory( pathToMyDir );
--- Quote ---2) Is it possible to write FITS keywords and values back when saving an ImageWindow?
--- End quote ---
The ImageWindow.keywords property is an array of FITSKeyword objects:
Array ImageWindow.keywords
The FITSKeyword object has name, value and comment String properties that you can read and write. It also has a constructor that allows you to set all of these properties at once:
new FITSKeyword( String name, String value[, String comment] )
Using the keywords property you can get and set FITS keywords for an image window before saving it. For example:
ImageWindow window = ImageWindow.activeWindow;
if ( !window.isNull )
window.keywords.push( new FITSKeyword( "MYKWD", 123.456, "my private keyword" ) );
Hope this helps.
kwiechen:
Thank you! Is a PJSR documentation available?
Best,
Kai
georg.viehoever:
--- Quote from: kwiechen on 2011 November 24 17:54:49 ---Thank you! Is a PJSR documentation available?
--- End quote ---
Not really. Your best bet is the bubble help that appear when you hover above function calls in the script editor browser window, and trying to derive the functionality from the PCL documentation http://pixinsight.com/developer/pcl/doc/index.html . Some of the Core Javascript Objects are also documented in Javascript tutorials (e.g. Array).
Of course, you can always ask in the forum, and Juan will usually help within in couple of days.
Georg
zvrastil:
Just to make sure it is not forgot, I'd like to cite Juan's word from this recent post: http://pixinsight.com/forum/index.php?topic=3585.msg24965#msg24965 >:D.
--- Quote ---
Then we'll have to start documenting the PJSR, which is another important pending task, but that's a different story.
--- End quote ---
cheers, Zbynek
Navigation
[0] Message Index
[#] Next page
Go to full version