Looks at transits between Earth and the Sun of Venus and Mercury
To get aggregated data, change personal_data_directory to the location of the aggregated data directory in this repository. To save new aggregated data, change aia_data_directory and hmi_data_directory to folders containing year data for those telescopes. These can be downloaded from JSOC. If using custom aia_data_directory and hmi_data_directory, you will likely need to save all wavelength data yourself instead of using aggregated data, unless your aia_data_directory and hmi_data_directory are the same as mine, since the aggregated data includes the absolute paths to those two directories.
-
readData(planet, wavelength)planetis the planet transit to usewavelengthis the wavelength to useReturns the saved data for that wavelength in list form, sorted by time
-
writeToFile(filepath, data)filepathis the filepath to write todatais the data to saveReturns
data -
readFromFile(filepath)filepathis the filepath to read fromReturns the file evaluated
This will turn, for example, a dictionary in the file into a dictionary in python
To change between inline pictures and separate windows for images, change the line starting with %matplotlib to end with either inline, qt, osx, or gtx depending.
-
showFancyImage(filepath, subplot=None, new_figure=True)filepathis a path to a FITS filesubplotis the argument passed into matplotlib's subplot function. Ifsubplot == Nonethen subplot is not used.If
new_figureis True, it creates a new matplotlib figure for the imageIt makes a sunpy map of the given file, and puts the map on screen
Returns the map
-
showArray(array, subplot=None, new_figure=True, color_map='Greys')Graphs the given
arrayusing the colors fromcolor_mapsubplotis the argument passed into matplotlib's subplot function. Ifsubplot == Nonethen subplot is not used.If
new_figureis True, it creates a new matplotlib figure for the graphed arrayReturns the array
-
showHistogramOfPixelIntensities(array, boxes=50, subplot=None, new_figure=True)Shows a histogram of elements of the given
arrayboxesis the number of separate bars to sort the elements of the array intosubplotis the argument passed into matplotlib's subplot function. Ifsubplot == Nonethen subplot is not used.If
new_figureis True, it creates a new matplotlib figure for the histogramNote: uses lots of ram
Returns the array, with all nan elements set to zero
-
showImage(filepath, split=no_split, rotate=no_rotate, replace_with_zero=False, subplot=None, new_figure=True)filepathis a path to a FITS filesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)If
replace_with_zerois true, it will replace the removed elements of the array with zeros, otherwise it graphs a truncated array.subplotis the argument passed into matplotlib's subplot function. Ifsubplot == Nonethen subplot is not used.If
new_figureis True, it creates a new matplotlib figure for the graphed arrayGraphs the array from the filepath, applying the split and rotate
-
getArrayFromFitsFile(filepath)filepathis a path to a FITS fileIf the file doesn't exist, wait for it to.
Returns the array from the given file
-
getHeaderFromFitsFile(filepath)filepathis a path to a FITS fileIf the file doesn't exist, wait for it to.
Returns the header from the given file
-
findFileByTimeSinceStartOfTransit(planet, time, wavelength)planetis the planet transit to usetimeis the time since the start of the transit to get the file fromwavelengthis the wavelength to useReturns the filepath to the FITS file closest to that time
-
getRotatedAndSplitArrayFromFitsFile(filepath, split=no_split, rotate=no_rotate, replace_with_zero=False)filepathis a path to a FITS filesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)If
replace_with_zerois true, it will replace the removed elements of the array with zeros, otherwise it returns a truncated array.Finds the array from the given file given file, then applies the given split and rotate parameters as needed
Returns the array created
-
getTotalData(filepath, split=no_split, rotate=no_rotate)filepathis a path to a FITS filesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)It ignores the negative items in the array and items with a value greater than the mean + std dev of the wavelength as a whole
Returns the sum of the image data in the fits file
-
getNumberOfPixels(filepath, split=no_split, rotate=no_rotate)filepathis a path to a FITS filesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)Returns the number of non-nan pixels
-
getExpTime(filepath)filepathis a path to a FITS fileNote: the HMI continuum doesn't have an exposure time, so returns a 1
Returns the saved exposure time of the file. This may be inaccurate, depending on the processing already done on the file
-
getActualExpTime(filepath)filepathis a path to a FITS fileReturns the actual exposure time of the file, based on the time stamps in the file header
-
getCountsPerSecond(filepath, split=no_split, rotate=no_rotate)filepathis a path to a FITS filesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)Returns the number of counts per second from the file, applying the split and rotation angle
-
getTimeSinceStartOfTransit(filepath)filepathis a path to a FITS fileReturns the time in seconds since the start of the recorded transit period
-
getDistanceToSunFromSDO(filepath)filepathis a path to a FITS fileReturns distance of the sun to the SDO in meters (DSUN_OBS)
-
getPlanetFromFile(filepath)filepathis a path to a FITS fileReturns either "venus" or "mercury"
-
getWavelengthFromFile(filepath)filepathis a path to a FITS file
mean_stddev_skew_median_dict is a dictionary of {"venus": (data mean, standard deviation, data skew, data median), "mercury": (data mean, standard deviation, data skew, data median)}
-
getDataMeanStdDevSkewMedian(filepath)filepathis a path to a FITS fileReturns tuple of (data mean, standard deviation, data skew, data median)
-
getDataMean(filepath)filepathis a path to a FITS fileReturns the data mean from the file header
-
getDataRMS(filepath)filepathis a path to a FITS fileReturns the data rms from the file header
-
getDataSkew(filepath)filepathis a path to a FITS fileReturns the data skew from the file header
-
getDataMedian(filepath)filepathis a path to a FITS fileReturns the data median from the file header
-
getMeanStddevSkewMedian(planet, wavelength)planetis the planet transit to usewavelengthis the wavelength to useReturns a tuple of (average data mean, average standard deviation, average data skew, average data median) for the wavelength
-
getDictOfMeanStddevSkewMedian(planet)planetis the planet transit to useReturns a dictionary of
{wavelength : (average data mean, average standard deviation, average data skew, average data median)}for all wavelengths -
saveMeanStddevSkewMedianDict(planet)planetis the planet transit to useSaves a dictionary of
{wavelength : (average data mean, average standard deviation, average data skew, average data median)}topersonal_data_directory``planetmean_stddev_skew_median.txt for all wavelengths -
readMeanStddevSkewMedianDict(planet)planetis the planet transit to useReturns the saved dictionary of
{wavelength : (average data mean, average standard deviation, average data skew, average data median)}frompersonal_data_directory``planetmean_stddev_skew_median.txt for all wavelengths
-
readListOfFiles(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Reads the saved data for that wavelength and gets the list of files from that
-
readListOfFilesAndTimeSinceStartOfTransit(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Reads the saved data for that wavelength and gets the list of (file, time) from that
-
readExposureTimeOfFiles(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Reads the saved data for that wavelength and gets the list of counts per second from that
-
readActualExposureTimeOfFiles(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Reads the saved data for that wavelength and gets the list of counts per second from that
-
readDistancefSunOfFiles(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Returns a list of the distance to the sun for all the files in the given wavelength
-
readDataMeansOfFiles(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Returns a list of the data means for all the files in the given wavelength
-
readTimeSinceStartOfTransitOfFiles(planet, wavelength, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usetime_blockis an array to limit the list to (see section "Time")Reads the saved data for that wavelength and gets the list of times from that
-
readCountsPerSecondOfFiles(planet, wavelength, split=no_split, rotate=no_rotate, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)time_blockis an array to limit the list to (see section "Time")Reads the saved data for that wavelength and gets the list of counts per second from that
-
getNumberOfPixelsOfFiles(planet, wavelength, split=no_split, rotate=no_rotate, time_block=[])planetis the planet transit to usewavelengthis the wavelength to usesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)time_blockis an array to limit the list to (see section "Time")Returns a list of the number of pixels for all the files in the given wavelength
All functions in this section are very slow, due to the large number of files being processed
-
findGoodFiles(planet, hour, wavelength)planetis the planet transit to usehouris what hour of the transit to get the data from, from "00" to "23"wavelengthis the wavelength to useReturns a list of non cutoff files
-
getAllGoodFiles(planet, wavelength)planetis the planet transit to usewavelengthis the wavelength to useReturns a list of all the non cutoff files
-
getDictOfAllGoodFilesAllThings(planet, wavelength)planetis the planet transit to usewavelengthis the wavelength to useReturns a dictionary of
filepath, (count, time, pixels, count_in_split, pixels_in_split, count_out_of_split, pixels_out_of_split) -
saveDictData(planet, wavelength, directory='/home/gtaylor/')planetis the planet transit to usewavelengthis the wavelength to usedirectoryis the directory to save the datafile toSaves a dictionary of all the good files for the wavelength : (their counts per second, their time since start of transit) to the data file for that wavelength
The saved data file is named
planetdatawavelength.txtReturns the dictionary
-
saveAllWavelengthData(planet, directory='/home/gtaylor/')planetis the planet transit to usedirectoryis the directory to save the datafile toEach saved data file is named
planetdatawavelength.txtFor all wavelengths, saves a dictionary of all the good files for the wavelength : (their counts per second, their time since start of transit) to the data file for that wavelength
-
saveAllWavelengthDataMultiThreaded(planet)planetis the planet transit to useFor all wavelengths, saves a dictionary of all the good files for the wavelength : (their counts per second, their time since start of transit) to the data file for that wavelength
Each saved data file is named
planetdatawavelength.txtDoes this in multiple threads (see section "Multithreading")
Due to limitations of multithreading, the directory to save data to is the default one from saveDictData
-
graphLightCurve(planet, wavelength, split=no_split, rotate=no_rotate, popt_one=[], func_one=None, popt_two=[], func_two=None, time_block=[], show_events=False, label="", wavelength_name=True, new_figure=True, scale_to_one=True, shift=0, scale_to_one_based_on="max", subplot=None)`planet` is the planet transit to usewavelengthis the wavelength to usesplitis the section of the array that is cared about (see section "Split and Rotate")rotateis the number of degrees to rotate the array by (counter clockwise)func_oneis a function (number, parameters) -> number that is applied to the light curve before graphing itpopt_oneis an array of optimized parameters forfunc_onefunc_twois a function (number, parameters) -> number that is applied to the light curve before graphing itpopt_oneis an array of optimized parameters forfunc_twotime_blockis an array to limit the list to (see section "Time")If
show_eventsis True, the graph of the light curve includes lines for various events that happen during the transit Shows the ingress and egress with black lines Shows midnight (venus transit only) with a green linelabelis text to add to the end of the data name that goes in the legendIf
wavelength_nameis True, the data name that goes in the legend includes the name of the wavelengthIf
new_figureis True, it creates a new matplotlib figure for the light curveIf
scale_to_oneis True, it scales the light curve to be on a scale of 0 to 1scale_to_one_based_ondecides how to scale the light curve, ifscale_to_oneis True "max" scales so that the maximum element is 1 "first" scales so that the first element is 1 "last" scales so that the last element is 1 "not transit" scales so that the average not transit element is 1shiftis added to every datapoint in the arrayfontsizeis the size of the text in the graphed light curve (doesn't include the tick mark labels)numbersizeis the size of the tick mark labels in the graphed light curveIf
show_graphis True, it graphs the light curvesubplotis the argument passed into matplotlib's subplot function. Ifsubplot == Nonethen subplot is not used.Returns a tuple of the array of times and the array of data values that were graphed
-
graphAmountCausedByDistance(planet, wavelength)planetis the planet transit to usewavelengthis the wavelength to useGraphs the light curve and a line representing how much of that was caused by the SDO moving in respect to the Sun
-
graphLightCurveAdjusted(planet, wavelength, show_events=False, use_primary_curve_fit=True, use_secondary_curve_fit=True, label="", wavelength_name=True, new_figure=True, scale_to_one=True, shift=0, force_primary_curve_fit=False, scale_to_one_based_on="max")Parameters that are also in graphLightCurve behave in the same way
If
use_primary_curve_fitis True, uses a primary curve fit to adjust the light curveIf
use_secondary_curve_fitis True, uses a secondary linear curve fit to adjust the light curveReturns a tuple of the array of times and the array of data values that were graphed
-
graphAllLightCurves(planet, split=no_split, rotate=no_rotate, time_block=[], show_events=False, label="", wavelength_name=True, new_figure=True, scale_to_one=True, remove=[], shift_up=False, all_new_figures=False, scale_to_one_based_on="max", shift_amount=0.0003)Parameters that are also in graphLightCurve behave in the same way
If
shift_upis True, graphs the light curves withshift_amountgap between themIf
all_new_figuresis True, graphs each light curve in a new figure, otherwise it graphs all the light curves in a single imageremoveis an array of wavelengths not to graph -
graphAllLightCurvesAdjusted(planet, use_primary_curve_fit=True, use_secondary_curve_fit=True, show_events=False, label="", wavelength_name=True, new_figure=True, scale_to_one=True, remove=[], shift_up=False, all_new_figures=False, scale_to_one_based_on="max", shift_amount=0.0003)Parameters that are also in graphLightCurve, graphAllLightCurves, or graphLightCurveAdjusted behave in the same way
-
graphWavelengthAndLimbDarkening(planet, wavelength, limb_darkening_model="quadratic", limb_darkening_parameters=None, depth=None, orbital_period_divider=11.3, semi_major_axis_const=14, new_figure=True)Parameters that are also in graphLightCurve behave in the same way
depthincreases the magnitude of the predicted light curve changesemi_major_axis_constandorbital_period_divideraffect the predicted light curve in strange waysGraphs the adjusted light curve and a predicted light curve based on the
limb_darkening_modelandlimb_darkening_parametersIf
limb_darkening_modelis "quadratic" andlimb_darkening_parametersis None, it uses parameters from Allen's Astrophysical Quantities
Functions that are of the form nth * x^n + n-1th * x^(n-1) + … + one * x + zero
They work for func_one and func_two for graphLightCurve
-
linear(x,one,zero) -
quadratic(x,two,one,zero) -
cubic(x,three,two,one,zero) -
quartic(x,four,three,two,one,zero) -
quintic(x,five,four,three,two,one,zero)
-
derotateWavelength(planet, wavelength, time_one=0, time_two=30000, file_one=None, file_two=None)planetis the planet transit to usewavelengthis the wavelength to usetime_oneis the time to derotate totime_twois the time to get an image from to derotate fromfile_oneis the file to derotate tofile_twois the file to get an image from to derotate fromDoesn't work for HMI Continuum
Returns the derotated image
-
showDiffBetweenTwoTimes(planet, wavelength, file_one=None, file_two=None, time_one=None, time_two=None, one_special=False, two_special=False)planetis the planet transit to usewavelengthis the wavelength to usetime_oneis the time to get an image from to difference totime_twois the time to get an image from to difference fromfile_oneis the file to get an image from to difference tofile_twois the file to get an image from to difference fromIf
one_specialis True, the array is stored in the first section of the first fileIf
two_specialis True, the array is stored in the first section of the second fileReturns the difference image
-
getFourierFrequencyData(planet, wavelength, show_graph=True, show_light_curve=False, seconds_between_points=24)planetis the planet transit to usewavelengthis the wavelength to useIf
show_graphis True, it graphs the frequency dataIf
show_light_curveis True, it graphs the light curve that produced the frequency dataseconds_between_pointsis the number of seconds between data points used for interpolation. Decreasing this number increases the accuracy of the function but increases the processing time it takes to run the function.Returns the result of a Fourier transform done on the planet and wavelength data, the data's linear spacing and interpolated points, and the data's average
-
getLowPassedData(planet, wavelength, show_graph=True, show_light_curve=True, seconds_between_points=24)planetis the planet transit to usewavelengthis the wavelength to useIf
show_graphis True, it graphs the low passed dataIf
show_light_curveis True, it graphs the light curveseconds_between_pointsis the number of seconds between data points used for interpolation. Decreasing this number increases the accuracy of the function but increases the processing time it takes to run the function.Returns the planet and wavelength data with a low pass filter applied
Source for this is How to create a simple low pass filter
-
getLowSquashedData(planet, wavelength, data_limit=0.0001, show_graph=True, show_light_curve=False, show_pre_change_frequency_graph=False, show_post_change_frequency_graph=False, seconds_between_points=24, slope_adjust=1.15)planetis the planet transit to usewavelengthis the wavelength to usedata_limitis the frequency value above which all frequency data is squashedIf
show_graphis True, it graphs the processed dataIf
show_light_curveis True, it graphs the light curve that produced the frequency dataIf
show_pre_change_frequency_graphis True, it graphs the unsquashed frequency dataIf
show_post_change_frequency_graphis True, it graphs the squashed frequency dataseconds_between_pointsis the number of seconds between data points used for interpolation. Decreasing this number increases the accuracy of the function but increases the processing time it takes to run the function.slope_adjustis a multiplier for the squashing. It helps to remove any ringingReturns the planet and wavelength data with the high frequency data squashed
time_block is an array of ["transit"|"not transit"|"ingress"|"egress"|"not venus spike"|number]
If it includes a string, it indicates to include times from that time period
If it includes "not venus spike", it indicates to remove times from that time period
If it includes number, it indicates only to use times before that number. This overrides everything else in time_block
-
venus_spike_start_time = 9000in seconds, the start of spike in 1700Å
-
venus_spike_end_time = 15000in seconds, the end of spike in 1700Å
-
ingress_start_time = {"venus":4020,"mercury":5010}in seconds, start of ingress
-
ingress_end_time = {"venus":5150,"mercury":5280}in seconds, end of ingress
-
egress_start_time = {"venus":26100,"mercury":31440}in seconds, start of egress
-
egress_end_time = {"venus":27350,"mercury":31680}in seconds, end of egress
-
transit_start_time = ingress_end_time -
transit_end_time = egress_start_time -
hours = {"venus":["21","22","23","00","01","02","03","04","05"],"mercury":["10","11","12","13","14","15","16","17","18","19","20"]}
-
checkIfInHours(hour, planet)Raises an exception if the given
houris not in the list of hours for the givenplanet -
timeSinceStartOfTransit(planet, time)planetis the planet transit to useGiven a
timesince the start of the recorded period, returns the difference between the given time and when the transit actually started -
timeThroughTransit(planet, time)planetis the planet transit to useGiven a
timesince the start of the recorded period, returns the start time if the transit has yet to start, the end time if the transit has already finished, or the current time -
checkTimeBlock(planet, time_block, time)planetis the planet transit to usetime_blockis an array to limit the list totimeis the time to checkChecks if
timeis in thetime_block -
getDataFromTimeBlock(planet, time_block, data, times)planetis the planet transit to usetime_blockis an array to limit the list to (see section "Time")datais an array of generic data points that correspond with the time points intimesdataandtimesmust be of same lengthReturns the data points that match the
time_block
-
transit_rotate = {"venus":7.4,"mercury":2.0}The angle to rotate the picture of the sun so that Venus goes horizontal through the image
-
no_rotate = 0
Splits are a dictionary of two tuples of two tuples each that are each in the format (w,[x,y,z,...]).
That is, it breaks the image into w slices and then uses slices x,y,z,... The first tuple is for AIA images, the second tuple is for HMI images
-
inside_split = {"venus":((32,[8]), (16,[3])),"mercury":((256,[159,160,161]), (256,[166,167,168]))}The section of the sun that contains the transit.
-
outside_split = {"venus":(((32,range(8) + range(9,32)), (16,range(3) + range(4,16)))),"mercury":((256,range(159) + range(162,256)), ((256,range(166) + range(169,256))))}The section of the sun that doesn't contain the transit
-
no_split = {"venus":(((1,[0]), (1,[0]))),"mercury":(((1,[0]), (1,[0])))}The entire sun
-
wavelengths = ["0094","0131","0171","0193","0211","0304","0335","1600","1700","cont"]cont= HMI intensity continuum, all other are AIA wavelengths
-
checkIfInWavelengths(wavelength)Raises an exception if
wavelengthis not in the list of wavelengths
data about Venus
-
venus_radius = 3760.4miles
-
sun_radius = 432168.6miles
-
venus_semi_major_axis = 67237909.0miles
-
venus_apparant_radius = 0.023stellar radii ((tangent of angular radius of venus on june 5th 2012)*(1 astronomical unit - radius of sun - radius of earth) / (radius of sun))
-
venus_longitude_perihelion = 131.53298degrees
-
venus_orbital_period_days = 224.701days
-
venus_orbital_period = venus_orbital_period_days * 24 * 60 * 60seconds
-
venus_eccentricity = 0.0067 -
venus_orbital_inclination = 3.39degrees
-
venus_time_inferior_conjunc = (transit_start_time["venus"] + transit_end_time["venus"] ) / 2seconds
This is based on ipython notebook features
-
%job [stuff to do] -
jobs.status()to check on jobs
-
jobs.traceback(num)for stack trace for dead thread
num -
kill_thread(jobs.all[num])to kill thread
num -
for thread in jobs.running:kill_thread(thread)Kill all running threads