// An imageJ macro to be used with exercice 
// Détection du cycle solaire
// by O. Marco
// Pour avoir les accents, enregistrer en format
// OCCIDENTAL WINDOWS LATIN 1
// sinon ça plante !


setBatchMode(false);

homeDir  =getDirectory("home");
macroDir = getDirectory("SalsaJ")+"Data/images_dm/";
remoteDir="http://www.euhou.net/SalsaJ/Data/images_dm/";

print("Home Dir: "+homeDir);
print("Macro Dir: "+macroDir);
print("Startup Dir: "+getDirectory("startup"));
print("Images Dir: "+getDirectory("image"));
print("Plugins Dir: "+getDirectory("plugins"));

print("Script to study the movements around the Black Hole");
print("Load all the necessary images and adjust contrast");

runMacro("Close_All_Windows.txt");

name="NGC7083.gif";
openImage(name,macroDir,remoteDir);
name="NGC7083_RID.FTS";
openImage(name,macroDir,remoteDir);

run("Sparer");
run("Tile");
run("Kachel");
run("Separar");
run("Disponi tutto");
run("Mosaico");
run("Sida vid sida");
run("Kaskada");

//run("Grays invert");
//runMacro("PropagateImageInversion");

function openImage(name,localDir,remoteDir){
	//print("name="+name);
	//print("local="+localDir);
	//print("remote="+remoteDir);
	if(! File.exists(localDir+name)){
		path=remoteDir+name;
		open(path);
		if (isOpen(name)) saveAs("FITS",localDir+name);
		else print(""+path+" is not opened");
	}
	else open(localDir+name);
}
