Commit 3e1e9d5e authored by jclamber's avatar jclamber
Browse files

add dmin/dmax to fits2uns

git-svn-id: http://svn.oamp.fr/repos/uns_projects/trunk@120 f264a43e-d52d-4b82-913b-c2bd5215a18a
parent 5b272f2c
......@@ -24,6 +24,7 @@ typedef char * string;
#include <uns.h>
#include <cmath>
#include <limits>
// The library is enclosed in a namespace.
......@@ -33,11 +34,12 @@ using namespace CCfits;
const char * defv[] = { // use `::'string because of 'using namespace std'
"in=???\n tipsy input file ",
"out=???\n output file)",
"type=gadget2\n nemo|gadget2",
"type=nemo\n nemo|gadget2",
"dmin=\n minimum data value",
"dmax=\n maximum data value",
"zmin=-1\n #z plane min",
"zmax=-1\n #z plane max",
"verbose=f\n verbose mode ",
"verbose=f\n verbose mode",
"VERSION=1.0\n compiled on <"__DATE__"> JCL ",
NULL
};
......@@ -45,6 +47,8 @@ const char * usage="Simple converter fits to uns compatible output format";
int readImage(std::string in, std::string out, std::string type,int zmin, int zmax);
float dmin = std::numeric_limits<float>::min();
float dmax = std::numeric_limits<float>::max();
int main(int argc, char ** argv )
{
......@@ -56,6 +60,12 @@ int main(int argc, char ** argv )
std::string outname (nos::getparam ((char *) "out" ));
int zmin (nos::getiparam ((char *) "zmin" ));
int zmax (nos::getiparam ((char *) "zmax" ));
if (nos::hasvalue((char *) "dmin")) {
dmin=(nos::getdparam ((char *) "dmin" ));
}
if (nos::hasvalue((char *) "dmax")) {
dmax=(nos::getdparam ((char *) "dmax" ));
}
std::string typeout = (nos::getparam ((char *) "type" ));
bool verbose = (nos::getbparam((char *) "verbose" ));
......@@ -144,7 +154,7 @@ int readImage(std::string in, std::string out, std::string type, int zmin, int z
std::cerr << "value = " << contents.size() << "\n";
for (unsigned long i=0; i<contents.size(); i++) {
if (std::isfinite(contents[i]) && contents[i]>1e-5 && contents[i] < 10.) {
if (std::isfinite(contents[i]) && contents[i]>dmin && contents[i] < dmax) {
long z_i=int(i/(ax*ay)); // current Z plane
assert(z_i<=az);
......@@ -166,6 +176,7 @@ int readImage(std::string in, std::string out, std::string type, int zmin, int z
}
}
std::cerr << " #NAN values = "<< nan << "\n";
std::cerr << " #bodies valids = "<< rho.size() << "\n";
uns::CunsOut * unsout = new uns::CunsOut(out,type,false);
std::string comp="gas";
if (type=="nemo") comp="all";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment