Skip to content

rapidsnow/Eclipse-Mapping

Repository files navigation

Compiling the C-code:
    Requires Numerical Recipes Header File (included) for C
    Requires the CFITSIO library to be installed
    The code standard is C99.
    Be sure to include the cfitsio libraries

    Example compile using gcc:
        gcc -std=c99 -Wall ../Eclipse\ Mapping/main.c -o main -lcfitsio -L/opt/local/lib

Running the compiled C code:
    For simplicity's sake, I'm going to assume that your code has been compiled into a file called main.
    Usage:
        ./main <input_file> <output_path>
        
    There is one additional option for the code. For use in lightcurve detrending (not eclipse mapping), there is an alternate output file type (Full BJD, non-normalized flux, non-normalized error) that will be automatically implemented if you end the above line in 1.
    For example:
        ./main <input_file> <output_path> 1

Input File:
    For right now, the input file can't accept any comments. I don't really know a good way to read comments in C. Anyway, each of the following parameters goes on one line of the file. You can check that your input file is correct by looking at readable_input.in after you've run the C code. It will print out information about each line corresponding with the value that you provided in that slot.

    1) Filename of input lightcurve
    2) Period of rotation of the star
    3) In transit binning cadence (in number of typical Kepler short-cadence timesteps)
    4) Out-of-transit binning cadence (in number of typical Kepler short-cadence timesteps)
    5) Orbital epoch (BJD)
    6) Transit width (Days)
    7) Orbital period (Days)
    8) Impact parameter
    9) Rp/R*
    10) Orbital separation (a/R*)
    11) Regularization factor for stripes
    12) Regularization factor for boxes
    13) Number of stripes
    14) Number of boxes
    15) PDC flag (Obsolete, always use PDC Flag, but if I don't get around to taking it out, set it to 1)
    16) Desired Days per window (We've been using around .75 of a full stellar rotation period)
    17) Desired Days per tick (affects where each window starts)
    18) LD Coefficient 1 (For quadratic limb darkening)
    19) LD Coefficient 2

Output Files:
    The following are all ASCII outputs of the eclipse mapping code:
        ub.out - Unbinned ASCII lightcurve for the full dataset provided
        binned.out - Fully binned lightcurve for the full dataset provided
        chi.out - The final (reduced) chi-squared value for the model light curve versus the data at each point.
        model_<x>.out - Model light curve fits to the data for each of a series of n windows
        trans_<x>.out - Beginning and ends of transits in units of array indices. This is my inelegant and eventually temporary solution to creating transit plots with my python scripts.
        brights_<x>.out - Set of {b1, ..., b_nboxes, b_nboxes+1, ..., b_nstripes} brightness values produced by the Amoeba Algorithm.
        readable_input.in - An easy check to make sure that all given values correspond to the right piece of information.
        
        Vis_Plots/files - a set of visibility files. The code to produce this should be commented out by default. However, if you uncomment it, you can have the visibilities output. z_<x>.out are the individual longitude vis curves. b_<x> are the individual box vis curves. sum_zvals.out is the sum of all of the longitudes at each timestep (should be 1.0 except for where the transits are). sum_bvals.out is the sum of all of the boxes at each timestep. sum_all.out is actually the sum of all of the longitudes minus the sum of all of the boxes for a given timestep... sorry for the misnomer, a relic.

Common problems:
    1) Numerical Recipes run-time error...
    NMAX exceeded
    ...now exiting to system...
    
    This issue usually occurs when the number of regions is too high, the binning cadence is too high (too many data points), or the window size is not small enough.
    
    2) Program returns 5 instead of 0. 
    
    I'm sure that there is some standard return that I am supposed to be using for this, but I don't know it. "5" means that there was a NULL pointer found instead of an open file or a properly allocated array. This is not something wrong with the code. Try to re-run the code. If it still won't work, it is likely something incompatible with the architecture of the computer that you are trying to run it on...?
    
    3) Error: File <filename> not opened correctly.
    
    Self-explanatory, except in the case of the Visibility outputs (if that section is not commented out). This is because the code is not set up to create directories and there is no directory in the output_path called "Vis_Plots/". You can either comment that section out or create a directory there called Vis_Plots. Visibility plots are still there for a purely diagnostic purpose and should really be left as commented.
    
    4) More...? I can't think of anything right now. Report it if you find it.
    
------------------------------------------------------------------------------------------------------
Python scripts:
    For the most part, all relevant classes and methods should have an explanatory head comment in them, so I'll just quickly detail these here.

    plots_scratch.py
        Contains all of the actual plotting methods, Star class, Region class, and Light_Curve class definitions. Usually run via make_plots.py, but you can try to figure out how to do it on your own if you want. It's pretty self-explanatory if you read the top comments for each method/class.
    model_maker.py
        Uses whitenoise.py and self-contained definitions to make synthetic lightcurves
    make_plots.py
        A template that I use to run certain plotting routines over many files. Very useful for the synthetic lightcurve tests.
    white_noise.py
        Contains file reading methods and noise-generating methods for taking a noiseless lightcurve and adding a given magnitude's Gaussian noise.
    run_new_spot_models.py
        VERY simple python wrapper that calls the C code on a given list of paths.
        
        
Walkthrough of making a synthetic lightcurve, trying to reproduce it, and making plots:
    1) Run a star through the eclipse mapping code with no binning in- or out-of-transit to produce a set of visibilities (make sure to uncomment that section)
    2) Create a directory to hold the lightcurve
    3) Create a description.txt file that contains the desired set of brightness values for producing the model curve
    4) Point model_maker.py (the if __name__ == '__main__' part at the bottom has the relative location of the description.txt file and Vis_Plots folder) to the right directory
        Subpoint, you can choose between noise levels, or no noise at this step in the bottom part of model_maker.py
    4) Do a wc in the shell on the produced model to get the number of lines
    5) Add two lines at the top of the produced model curve (I like to make a copy so I can still easily plot it). The first line is the number of lines in the file before you add the two new ones (the wc value). The second line is the desired epoch. For most synthetic curves, this will be zero.
    6) Make sure that your test.in file is pointing to the file you just created with the extra two lines and that all of the parameters are correct for the system.
        You will need to keep in mind that the time units are now in orbital phase, and so anything to do with time (duration, epoch, stellar rotation period, orbital period, etc.) will need to be divided by the orbital period to match the new curve (sorry that's kind of a hassle, but it's what I do).
    7) Compile the latest version of the C code if it isn't already compiled (see above)
    8) Run the C code pointing to the test.in that you just created and the desired output location (usually the directory made in step 2)
    9) Add the directory created in step 2 to whatever pathlist is in make_plots.py
    10) Choose the options in make_plots.py for what plots you want to make
    11) Run python make_plots.py and then look at your plots!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published