Hi there,
I am prepared to add a read file class in Atmosphere, which includes a set of density values.
But I usually use python, very rookie in Java, which makes me big trouble.
I wrote the java class as follows,
package org.orekit.models.earth.atmosphere;
import java.io.*;
import org.hipparchus.CalculusFieldElement;
import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
import org.orekit.bodies.BodyShape;
import org.orekit.bodies.FieldGeodeticPoint;
import org.orekit.bodies.GeodeticPoint;
import org.orekit.frames.Frame;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.FieldAbsoluteDate;
public class SimpleAtmosphere implements Atmosphere {
/** Serializable UID.*/
private static final long serialVersionUID = 2772347498196369601L;
/** Earth shape model. */
private BodyShape shape;
/** Create an exponential atmosphere.
* @param shape body shape model
*/
public SimpleAtmosphere(final BodyShape shape) {
this.shape = shape;
}
/** {@inheritDoc} */
public Frame getFrame() {
return shape.getBodyFrame();
}
/** {@inheritDoc} */
public double getDensity(final AbsoluteDate date, final Vector3D position, final Frame frame) {
String path = "D:\\Desktop\\OrbitalPropagator\\density.txt";
File file = new File(path);
if (!file.exists()){
System.exit(0);
}
BufferedReader reader = null;
String temp = null;
String rho0 = null;
// define date
try {
reader = new BufferedReader(new FileReader((file)));
while((temp = reader.readLine())!=null){
String[] linenow = temp.split(" ");
String year = linenow[0];
String month = linenow[1];
String day = linenow[2];
String time = linenow[3];
String density = linenow[10];
String date1 = date.toString();
String year1 = date1.substring(0, 4);
String month1 = date1.substring(5, 7);
String day1 = date1.substring(8, 10);
String time1 = date1.substring(11, 19);
if (year.equals(year1) ){
if (month.equals(month1) ) {
if (day.equals(day1) ) {
String rho3 = density;
if (time.equals(time1) ){
rho0 = density;
break;
}
}
}
}
}
}
catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
catch (IOException e) {
throw new RuntimeException(e);
}
double rho = Double.parseDouble(rho0);
return rho ;
}
}
I try to imitate a simple model in the Atmosphere class.
But I still could not let it work.
If you could teach me about the reason, I would be very grateful!!
Thank you!
Roint