Code Monkey home page Code Monkey logo

echellesimulator's People

Contributors

stuermer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

echellesimulator's Issues

Improve random generation number handing

There are two issues with the current random number handling:

  1. For a 'too many' number of wavelength, the code will fail, because the vectors won't fit into memory.
    Suggestion: create chunks of wavelength that can fit into memory. Maybe dynamically adjust size of chunks with respect to available memory and loop through chunks ?

  2. Random number generation should be separated completely from the tracing.

One function should generate a vector of N uniformly distributed values that are used for sampling in the slit, the wavelength and the PSF.
By separating the process, it can more easily replaced with a CUDA function.
The tracing function should then access a member variable that stores the random numbers.

With the implementation right now, the PSF randomization does not allow calculating how many random numbers there are needed in advance.
Therefore, the function that generates 'new' random numbers should be triggered by e.g. the trace function as soon as all so far generated numbers have been used.
Possible issues: thread safety ? Slowdown due to if statement ?

--custom spectra not currently functional?

I'm trying to input a custom, continuous spectrum using the --custom1 and --custom2 options, but can't get it to work. Is this a currently functional feature or was it a planned feature? The only documentation I see on it is in the --help.

I've tried this with both docker and a local installation and the results are the same. No matter what I input, using --custom1 or custom2 always leads me to either a segmentation fault or CCFits can't read. I don't know what the expected format is for the custom spectra, but based on the code, I'm assuming it is meant to have the same format as the phoenix files.

When I look at how the custom1 and 2 arguments call the CustomSpectra class, to me the variables don't seem to line up with what is listed with --help, which leads me to believe this is not yet a functional feature? If not, is there any suggestion on how to hack it?

Thanks in advance!

GUI

Write a GUI for selecting sources/spectrograph etc. and performing simulation

Speed up PSF sampling

Possible speedup by implementing the following approach:

  • create lookup table for PSF probability function for marginal probability function in one direction e.g. X
  • draw from marginal probability function to retrieve x
  • calculate conditional probability function of Y for given x and draw y from it

relative intensities when using --linelist option

When creating simulated spectra with the --linelist option (eg a ThAr spectrum), I am not sure if the counts in the spectrum are correct. That is, when providing a line list table in the format "wavelength; relative_intensity", the counts in the lines in the fits file do not seem to be correlated with the relative intensities.

For example, here is an extract of a ThAr linelist showing 6 lines with vastly different relative intensities:
0.93310500; 1
0.93359800; 0
0.93361619; 210
0.93364483; 38
0.93387676; 46
0.93407047; 2400

But the extracted spectrum looks like this:
thar_example

Automatic download of phoenix spectra

Implement automatic download of phoenix spectra for a given parameter set (I believe it's temperature, log g and metallicity).

Add optional command line arguments for these three parameters.
Download image into subfolder if file doesn't exist - otherwise use local file.

Segmentation Fault error at prepare PSFs step

Hi Julian, I ran EchelleSimiulator on a spectrograph model I generated and I got a Segmentation Fault at the "Prepare PSFs" step. Any clues as to why? The HDF model file looks like it has some PSFs stored in it. I attached the model creation script I used.
model_creation_iranti.txt

Running my EchelleSimulator build on the MaroonX example seems to be working.

Documentation

Insert missing documentation, especially for the Sources class (Phoenix) and the random generator.

Update Readme.md file and account for 'photon mode' rather than 'warping'

Update readme file and with examples that include the use of command line arguments

interpolation not working for Phoenix spectra

if you provide values that do not exist in the Phoenix library, it will crash and not interpolate (as suggested by
./echellesiulator --help"
--> intermediate values will be rounded to available spectra"

eg. ./echellesimulator -s VeloceRosso -p 3800.,4.65,0.,0.,0. -t 1 -k 0 -r 0 -f 1 -o M5V.fit

will crash because there is a Phoenix spectrum for log g = 4.5 and one for 5.0 but none for 4.65

Implement 'photon' mode

'Photon' mode should be implemented:
Instead of warping a slit illumination, a 'single photon' mode should also be implemented.
It is basically a raytracing mode, using the transformation matrix to determine where a photon ends up on the CCD.
The slit illumination provides the probability distribution where the photon starts. The spectrum provides the probability distribution which wavelength the photon has. Not sure how to implement PSF. Can probably be used as probability distribution of how the photon is redistributed after tracing on the CCD.

"-c / --constant" flag not working properly

When using the "-c" flag when calling echellesimulator (like below), it crashes:

I called the program via:
./echellesimulator -s VeloceRosso -t 1000 -k 1 -f 1 -c 2 0 1 -o test_01.fit
and got the following messages:

Spectrograph file found
Read in 42 Orders

Iterating over elements in the file
Simulating constant source with spectral density = 2 [micro watt] / ([micro meter] * [meter]^2)
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stod
Aborted (core dumped)

lookup table for matrix parameters

Write lookup tables - similar as it is done for the PSFs - for all matrix parameters except tx and ty.
All parameters should be calculated ONCE for each order in advance of tracing.

optional:
write lookup table also for tx, ty as well as for dtx and dty (numerical derivatives of tx and ty)
for Interpolating tx and ty use difference dLambda between lookup table wavelength and 'true' wavelength correct linearly with dtx and dty respectively. (similar to what is used to interpolate CDF)

PHOENIX spectra flag

There seems to be a problem with the PHOENIX spectra flag.

  1. In the documentation ./echellesimulator -h , the order of the parameters does not match what is passed to the ftp download command. I think the correct syntax should be --phoenix/-p T_eff, log_g, Z, alpha, Mag
  2. The download results in a crash. While I can manually download wget ftp://phoenix.astro.physik.uni-goettingen.de/HiResFITS/PHOENIX-ACES-AGSS-COND-2011/Z-0.0/lte06200-5.00-1.0.PHOENIX-ACES-AGSS-COND-2011-HiRes.fits, if I run eg ./echellesimulator -s VeloceRosso -p 6200,5.,-1.,0.,1 -t 1 -k 1 -f 1 -o test.fitthis results in screen output like this:
Spectrograph file found
Read in 42 Orders

Iterating over elements in the file
Simulating phoenix spectra with magnitude = 1
Downloading spectra from: ftp://phoenix.astro.physik.uni-goettingen.de/HiResFITS/PHOENIX-ACES-AGSS-COND-2011/Z-1.0/lte06200-5.00-1.0.PHOENIX-ACES-AGSS-COND-2011-HiRes.fits
Segmentation fault (core dumped)

ie the parameters are used correctly in the filename, but the download does not succeed. I have never used the PHOENIX library before, so I don't know if the problem lies in the EchelleSimulator code or within the PHOENIX library.

Develop proper file format for spectrograph model

Different spectrographs should be described by a single file containing all necessary information.
HDF as a file format is probably the way to go.

The script that extract information from ZEMAX should save everything in one file.

Argparse

Implement command line arguments to replace hard coded parameters:

Use https://github.com/hbristow/argparse for implementation. That looks nice !

Goal would be to have commands like that:
echelle++ --spectrograph MaroonX --source etalon --t 10 for a t=10s integration of a etalon spectrum
or
echelle++ --spectrograph MaroonX --fiber 1 --source mdwarf 3500 4.0 -0.1 --mag 10 --t 200 for a 200s integration of a magintude 10 mdwarf with T=3500 effective temperature log g=4 and metallicity of -0.1

(command line arguments can be added in CLion via Run -> Edit Configurations -> Program arguments)

etc.
Required parameters should be:
--m : name of spectrograph model
--t (integration time) : integration time of the camera
--s (source) : name of source
--o (output) : path of output file
Optional parameters should be:
--fibers or maybe list of to select which fiber should be
-- optional parameters for sources e.g. see above for mdwarfs, reflectivity, distance etc. for etalon, temperature for blackbody etc.

Creating new spectrograph hdf unsuccessful

echellesimulator_output.txt
I'm a graduate student working on a grism based cross dispersed spectrometer (RIMAS). Currently, I'm trying to simulate some RIMAS data via your stuermer/echellesimulator docker image. I've created an HDF file for RIMAS's Y and J bands optical arm, and managed to get the simulation to run (output attached), but it doesn't find photons within any of the orders. Would you mind taking a look at what I've done, or answering some questions about the hdf file requirements for the simulation? I've been working on this for a while now, and I'm stuck at this point.

Some notes on what I've tried so far:

  • All of my code, the hdf file and the Zemax files can be found here: https://github.com/joedurbak/echelle_simulator_model_creation

  • pyzdde doesn't seem to work very well with my version of Zemax so I did the following for the psfs and affine transformations:

    • I generated the Huygen PSFs in Zemax using the builtin functions, and created text files like this one and brought it into python using the get_psfs function on line 152 in this python file
    • I created a macro for the affine transformation dependencies that output this file
      • The output was parsed and affine transformations calculated using the do_affine_transformations function on line 170 within this python file
    • Even though my dispersion direction within the orders is actually along the y-axis, I deliberately swapped the axes when reading the data into python in case this was causing any issues with the simulation

Container exits with segfault

Trying to run the container on dockers exits after downloading the fits file. Upon closer inspection I noticed that running echellesimulator with the params provided in the example, crashes the simulator.

root@718253d05be1:/home/build#` ./echellesimulator --spectrograph MaroonX --phoenix 3500,-1.,0.,5.5,1 -r 100 -o mdwarf.fits
Spectrograph file found: ../data/spectrographs/MaroonX.hdf
Read in 33 Orders

Iterating over elements in the file
Simulating phoenix spectra with magnitude = 1
Trying to download PHOENIX Spectrum with: T_eff=3500 log_g=5.5 z=-1 Alpha=0
Downloading spectra from: ftp://phoenix.astro.physik.uni-goettingen.de/HiResFITS/PHOENIX-ACES-AGSS-COND-2011/Z-1.0/lte03500-5.50-1.0.PHOENIX-ACES-AGSS-COND-2011-HiRes.fits
Segmentation fault (core dumped)`

planned enhancements

  • add field points in python script rather than ZEMAX
  • trace 'unit square' of e.g. 100x100micron and scale accordingly to different fiber sizes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.