package newExamples.archive;
import gaia.cu1.params.GaiaParam;
import gaia.cu1.tools.dal.gbin.GbinFactory;
import gaia.cu1.tools.dal.gbin.GbinReader;
import gaia.cu1.tools.dm.GaiaRoot;
import gaia.cu1.tools.exception.ErrorMessageFormat;
import gaia.cu1.tools.exception.GaiaException;
import gaiasimu.GaiaSimuEnums.FoV;
import gaiasimu.SimuException;
import gaiasimu.gaia.Gaia;
import gaiasimu.gaia.payload.psf.CachePSFManager;
import gaiasimu.universe.generator.ExoPlanetGenerator;
import gaiasimu.universe.outputfile.WriteMDBICD;
import gaiasimu.universe.source.AstroSource;
import gaiasimu.universe.source.AstrometricParam;
import gaiasimu.universe.source.Photometry;
import gaiasimu.universe.source.stellar.OrbitalParams;
import gaiasimu.universe.source.stellar.SpectralType;
import gaiasimu.universe.source.stellar.StarPhysicalParameters;
import gaiasimu.universe.source.stellar.StellarAstrometry;
import gaiasimu.universe.source.stellar.StellarSource;
import gaiasimu.utils.cache.CacheManager;
import gog.GogAsciiWriter;
import gog.GogConstants;
import gog.GogGlobals;
import gog.GogSimulation;
import gog.MDBObject;
import gog.RunnableGogSimulation;
import gog.combined.CombinedData;
import gog.combined.CombinedDataWriter;
import gog.configuration.GogConfiguration;
import gog.configuration.GogConfigurationException;
import gog.configuration.GogConfigurationMgr;
import gog.epoch.EpochData;
import gog.epoch.EpochDataWriter;
import gog.exception.GogErrorMessageKeys;
import gog.exception.GogException;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import newExamples.gaia.cu4.du438.current_cycle.DmsSimuDU437;
// TODO: Auto-generated Javadoc
/**
* The Class Test.
*/
public class GenerateSimulateOnePlanet2 {
/**
* The main method.
*
* @param args the arguments
*
* @throws SimuException the simu exception
* @throws IOException
* @throws GaiaException
*/
public static void main(String[] args) throws SimuException, IOException, GaiaException{
// GOG configuration file
String[] gogConfig = { "newDataInput/gogconfig.xml" };
// Output UMSellar.gbin directory
String umStellarFileDir = "newGogTemp/";
String umStellarFile = umStellarFileDir + "UMStellar.gbin";
String gogOutputDir = "newDataOutput/";
String[] gogOutputFiles = {
gogOutputDir + "gog7beta_combinedAstrometric.gbin",
gogOutputDir + "gog7beta_combinedAstroPhysical.gbin",
gogOutputDir + "gog7beta_combinedPhotometric.gbin",
gogOutputDir + "gog7beta_combinedRVS.gbin",
gogOutputDir + "gog7beta_epochAstrometric.gbin",
gogOutputDir + "gog7beta_epochPhotometric.gbin",
gogOutputDir + "gog7beta_epochRVS.gbin",
gogOutputDir + "gog7beta_sourceRVS.gbin" };
// Exoplanet orbital parameters
double eccentricity = 0.1;
double inclination = 1 * Math.PI / 2; // (rad)
double nodeAngle = 0.4; // position angle of the line of nodes (rad)
double omega2 = 0.1; // argument of periastron (rad)
double period = 900; // (days)
double semiMajorAxis = 0.2; // semi-maj. axis (A.U.) of the secondary (a2)
double timePeriastron = 1.0; // (days)
//double massPlanet = 50; // (Jupiter masses)
double massPlanet = 50; // (Jupiter masses)
// Generate orbital parameters
/*
OrbitalParams orbitalParams = new OrbitalParams(
period,
timePeriastron,
semiMajorAxis,
eccentricity,
omega2,
inclination,
nodeAngle);
*/
// Star data
long idRoot = 1223345453L;
double magMv = 12.0; // Absolute magnitude
double vMinusI = 2.0; // Intrinsec Mean (V-I) colour
double absV = 0.1; // Interstellar absortion in the V band
double ra = 344.3665854; // RA ICRS (deg)
double dec = 20.76883222; // DEC ICRS (deg)
//double parallax = 65.10; // (mas)
//double muRa = 208.07; // Proper motion RA (mas/yr)
//double muDec = 60.96; // Proper motion DEC (mas/yr)
double parallax = 10; // (mas)
double distance = 1000 / parallax;// (pc)
double muRa = 5; // Proper motion RA (mas/yr)
double muDec = 5; // Proper motion DEC (mas/yr)
double vRad = -31.2; // Radial velocity (km/s)
double feH = 0.1; // [Fe/H]
double alphaE = 0.0; // Alpha elements enhancement
double mass = 1.2; // (Msun?)
double magBol = 4.3; // (Compute from bolometric corrections in Allen)
int pop = 6; // (Besancon model. 6: 5-7 Gyr)
String spType = "B5IV"; // String defining the spectral type
double teff = 5500; // (K?)
double logg = 4.4; // log g (cgs)
double radius = 2.0; // (Rsun?)
// Generate spectral type
SpectralType spectralType = new SpectralType( spType );
// Generate photometry
Photometry photometry = new Photometry(magMv, distance, vMinusI, absV);
// Generate astrometry
StellarAstrometry stellarAstrometry = new StellarAstrometry(
new AstrometricParam(ra, dec, parallax, muRa, muDec, vRad));
// Generate physics.
// Basic constructor for StarSystem
StarPhysicalParameters starPhysicalParameters =
// new StarPhysicalParameters( teff, feH, logg, mass, spectralType, magBol, radius, pop);
new StarPhysicalParameters(mass, spectralType, magBol, pop, feH, alphaE);
// Generate star
gaiasimu.universe.source.stellar.Star star =
new gaiasimu.universe.source.stellar.Star(
idRoot, photometry, stellarAstrometry, starPhysicalParameters);
// Exoplanet generator
ExoPlanetGenerator exoPlanetGenerator = new ExoPlanetGenerator();
// Generate exoplanet
//StellarSource exoplanet = exoPlanetGenerator.generateSystem( star, orbitalParams );
/* Exception in thread "main" gaiasimu.SimuException: Mass of component 1 not initialized
at gaiasimu.universe.source.stellar.StarSystem.computeMass(StarSystem.java:171)
at gaiasimu.universe.source.stellar.StarSystem.setPhysicalParameters(StarSystem.java:153)
at gaiasimu.universe.source.stellar.StarSystem.<init>(StarSystem.java:115)
at gaiasimu.universe.generator.ExoPlanetGenerator.generateSystem(ExoPlanetGenerator.java:174)
at newExamples.GogGbinTest.main(GogGbinTest.java:232)
*/
// DU437 simulator
DmsSimuDU437 dmsSimuDU437 = new DmsSimuDU437();
OrbitalParams orbitalParams2 = dmsSimuDU437.generateOrbitalParams(
star, massPlanet, period, timePeriastron, eccentricity, omega2, nodeAngle, inclination);
StellarSource systemRandom = dmsSimuDU437.generate(star, new Random());
StellarSource systemOnePlanet = dmsSimuDU437.generateSystem(star, orbitalParams2);
// Write sources to UMStellar file
ArrayList<gaiasimu.universe.source.AstroSource> objList = new ArrayList<gaiasimu.universe.source.AstroSource>() ; // simulated data
//objList.add( systemRandom );
objList.add( systemOnePlanet );
// Erase old UMStellar file, if available, and write the new one
( new File ( umStellarFile ) ).delete();
WriteMDBICD writer = new WriteMDBICD( umStellarFileDir );
writer.launchWrite( objList, false );
// Erase ould GOG output files, if available
for (String gogOutputFile : gogOutputFiles){
( new File ( gogOutputFile ) ).delete();
};
// Run GOG
//GogRun.main( gogConfig );
// Fragment GOG into pieces
// a) Parse command line arguments
String gogConfigFileAbsName = gogConfig[0];
String simulationId = new Long(System.currentTimeMillis()).toString();
// b) Basic steps
GogConfigurationMgr.getConfig( gogConfigFileAbsName, simulationId );
CachePSFManager.setPsfDir( GogGlobals.getPsfPath() );
CacheManager.getInstance("gaiasimu-cache.xml");
// c) Main execution method of the Gog simulation.We split the execution process in the following subprocesses
// 1 - Gaia initialization
GogConfiguration gc = GogConfigurationMgr.getConfiguration();
// 2 - Generation of the list of sources according the universe model or user sources given as input
RunnableGogSimulation gogSimulation = new RunnableGogSimulation( gc.getSimulationReference() );
// 3 - Delegation to the subprocess that perform astrosourcelist analysis and MDBObject calculation and writting
// gogSimulation.run();
// start time
// initialisation common to processSource and processSpectra : go
List<gaiasimu.universe.source.AstroSource> sourceList = gogSimulation.initSources();
// gogSimulation.processSourceList(sourceList);
int sourceListSize = sourceList.size();
// go
for (int i = 0; i < sourceListSize; i++) {
// write AstroSource in the universe model catalogue data
// gaiasimu.universe.source.AstroSource as = (AstroSource) systemOnePlanet;
gaiasimu.universe.source.AstroSource as = sourceList.get(i);
Random random = new Random();
random.setSeed(i);
// gogsprocessSource(as, random);
Gaia gaia = GogSimulation.getGaia();
// AstroSource as= (AstroSource)aSourcesList.get(i).getComponents()[j];
gaia.cu1.tools.numeric.algebra.GVector3d positionICRS = as.getAstrometry().getICRSPosition(GogConstants.CATALOGUE_TIME);
// compute all possible transits for this source, using ScanningLaw.inverseScan
double halfAperture = GaiaParam.Satellite.FOV_AC * GaiaParam.Nature.DEGREE_RADIAN / 2;
// This method returns the list of all the transits
List<gaiasimu.gaia.spacecraft.Transit> fovTransits = gaia.attitude.inverseScan(positionICRS, halfAperture, gaia
.getTelescope(FoV.FOV1));
List<gaiasimu.gaia.spacecraft.Transit> fovTransits2 = gaia.attitude.inverseScan(positionICRS, halfAperture, gaia
.getTelescope(FoV.FOV2));
// System.out.println("HA:" + halfAperture + "HA2:" +halfAperture2 + "ZA:" + zAngle + "ZA2:" + zAngle2);
fovTransits.addAll(fovTransits2);
// Compute epoch data
ArrayList<EpochData> epochData = new ArrayList<EpochData>();
boolean isPhotFromSpectrum = gc.isPhotometryFromSpectrum();
for( int j=0; j< fovTransits.size() ; j++) {
// WE compute the observable source from the UM_REF_TIME instead of the START_OF_MISSION
gaiasimu.GaiaSimuTime observableTime = fovTransits.get(j).getGSTime(); //
epochData.add(new EpochData(new gaiasimu.universe.source.ObservableSource (
as, observableTime, isPhotFromSpectrum), fovTransits.get(j).getFov(), random, i));
}
System.out.printf("W: %20.10e\n", epochData.get(0).getAstroData().getW() );
}
}
}