From 8c46f405905cf40a353914f466d4b89fac59709a Mon Sep 17 00:00:00 2001 From: elizabethg60 Date: Thu, 28 Mar 2024 09:45:45 -0400 Subject: [PATCH] wavelength --- example_spec.jl | 177 +++++++++++++++++++++++++++++++++++++ src/GRASS.jl | 8 ++ src/convenience_eclipse.jl | 8 +- src/disk_sim_eclipse.jl | 4 +- src/eclipse_comp.jl | 4 +- src/star_physics.jl | 8 +- 6 files changed, 199 insertions(+), 10 deletions(-) create mode 100644 example_spec.jl diff --git a/example_spec.jl b/example_spec.jl new file mode 100644 index 00000000..3e62a389 --- /dev/null +++ b/example_spec.jl @@ -0,0 +1,177 @@ +using GRASS +using Printf +using Revise +using SPICE +using Statistics +using EchelleCCFs +using BenchmarkTools + +GRASS.get_kernels() + +case = "Gottingen" + +if case == "NEID" + neid_timestamps = ["2023-10-14T15:26:45:500000", "2023-10-14T15:28:07:500000", "2023-10-14T15:29:30:500000", "2023-10-14T15:30:53:500000", "2023-10-14T15:32:15:500000", "2023-10-14T15:33:38:500000", "2023-10-14T15:35:01:500000", "2023-10-14T15:36:23:500000", "2023-10-14T15:37:46:500000", "2023-10-14T15:39:09:500000", "2023-10-14T15:40:31:500000", "2023-10-14T15:41:54:500000", "2023-10-14T15:43:17:500000", "2023-10-14T15:44:39:500000", "2023-10-14T15:46:02:500000", "2023-10-14T15:47:25:500000", "2023-10-14T15:48:47:500000", "2023-10-14T15:50:10:500000", "2023-10-14T15:51:33:500000", "2023-10-14T15:52:56:500000", "2023-10-14T15:54:18:500000", "2023-10-14T15:55:41:500000", "2023-10-14T15:57:04:500000", "2023-10-14T15:58:26:500000", "2023-10-14T15:59:49:500000", "2023-10-14T16:01:12:500000", "2023-10-14T16:02:34:500000", "2023-10-14T16:03:57:500000", "2023-10-14T16:05:20:500000", "2023-10-14T16:06:42:500000", "2023-10-14T16:08:05:500000", "2023-10-14T16:09:28:500000", "2023-10-14T16:10:50:500000", "2023-10-14T16:12:13:500000", "2023-10-14T16:13:36:500000", "2023-10-14T16:14:58:500000", "2023-10-14T16:16:21:500000", "2023-10-14T16:17:44:500000", "2023-10-14T16:19:06:500000", "2023-10-14T16:20:29:500000", "2023-10-14T16:21:52:500000", "2023-10-14T16:23:15:500000", "2023-10-14T16:24:37:500000", "2023-10-14T16:26:00:500000", "2023-10-14T16:27:23:500000", "2023-10-14T16:28:45:500000", "2023-10-14T16:30:08:500000", "2023-10-14T16:31:31:500000", "2023-10-14T16:32:53:500000", "2023-10-14T16:34:16:500000", "2023-10-14T16:35:39:500000", "2023-10-14T16:37:01:500000", "2023-10-14T16:38:24:500000", "2023-10-14T16:39:47:500000", "2023-10-14T16:41:09:500000", "2023-10-14T16:42:32:500000", "2023-10-14T16:43:55:500000", "2023-10-14T16:45:17:500000", "2023-10-14T16:46:40:500000", "2023-10-14T16:48:03:500000", "2023-10-14T16:49:25:500000", "2023-10-14T16:50:48:500000", "2023-10-14T16:52:11:500000", "2023-10-14T16:53:33:500000", "2023-10-14T16:54:56:500000", "2023-10-14T16:56:19:500000", "2023-10-14T16:57:42:500000", "2023-10-14T16:59:04:500000", "2023-10-14T17:00:27:500000", "2023-10-14T17:01:50:500000", "2023-10-14T17:03:12:500000", "2023-10-14T17:04:35:500000", "2023-10-14T17:05:58:500000", "2023-10-14T17:07:20:500000", "2023-10-14T17:08:43:500000", "2023-10-14T17:10:06:500000", "2023-10-14T17:11:28:500000", "2023-10-14T17:12:51:500000", "2023-10-14T17:14:14:500000", "2023-10-14T17:15:36:500000", "2023-10-14T17:16:59:500000", "2023-10-14T17:18:22:500000", "2023-10-14T17:19:44:500000", "2023-10-14T17:21:07:500000", "2023-10-14T17:22:30:500000", "2023-10-14T17:23:52:500000", "2023-10-14T17:25:15:500000", "2023-10-14T17:26:38:500000", "2023-10-14T17:28:01:500000", "2023-10-14T17:29:23:500000", "2023-10-14T17:30:46:500000", "2023-10-14T17:32:09:500000", "2023-10-14T17:33:31:500000", "2023-10-14T17:34:54:500000", "2023-10-14T17:36:17:500000", "2023-10-14T17:37:39:500000", "2023-10-14T17:39:02:500000", "2023-10-14T17:40:25:500000", "2023-10-14T17:41:47:500000", "2023-10-14T17:43:10:500000", "2023-10-14T17:44:33:500000", "2023-10-14T17:45:55:500000", "2023-10-14T17:47:18:500000", "2023-10-14T17:48:41:500000", "2023-10-14T17:50:03:500000", "2023-10-14T17:51:26:500000", "2023-10-14T17:52:49:500000", "2023-10-14T17:54:11:500000", "2023-10-14T17:55:34:500000", "2023-10-14T17:56:57:500000", "2023-10-14T17:58:20:500000", "2023-10-14T17:59:42:500000", "2023-10-14T18:01:05:500000", "2023-10-14T18:02:28:500000", "2023-10-14T18:03:50:500000", "2023-10-14T18:05:13:500000", "2023-10-14T18:06:36:500000", "2023-10-14T18:07:58:500000", "2023-10-14T18:09:21:500000", "2023-10-14T18:10:44:500000", "2023-10-14T18:12:06:500000", "2023-10-14T18:13:29:500000", "2023-10-14T18:14:52:500000", "2023-10-14T18:16:14:500000", "2023-10-14T18:17:37:500000", "2023-10-14T18:19:00:500000", "2023-10-14T18:20:22:500000", "2023-10-14T18:21:45:500000", "2023-10-14T18:23:08:500000", "2023-10-14T18:24:30:500000", "2023-10-14T18:25:53:500000", "2023-10-14T18:27:16:500000", "2023-10-14T18:28:38:500000", "2023-10-14T18:30:01:500000", "2023-10-14T18:31:24:500000", "2023-10-14T18:32:47:500000", "2023-10-14T18:34:09:500000", "2023-10-14T18:35:32:500000", "2023-10-14T18:36:55:500000", "2023-10-14T18:38:17:500000", "2023-10-14T18:39:40:500000", "2023-10-14T18:41:03:500000", "2023-10-14T18:42:25:500000", "2023-10-14T18:43:48:500000", "2023-10-14T18:45:11:500000", "2023-10-14T18:46:33:500000", "2023-10-14T18:47:56:500000", "2023-10-14T18:49:19:500000", "2023-10-14T18:50:41:500000", "2023-10-14T18:52:04:500000", "2023-10-14T18:53:27:500000", "2023-10-14T18:54:49:500000", "2023-10-14T18:56:12:500000", "2023-10-14T18:57:35:500000", "2023-10-14T18:58:57:500000", "2023-10-14T19:00:20:500000", "2023-10-14T19:01:43:500000", "2023-10-14T19:03:06:500000"] + #convert from utc to et as needed by SPICE + time_stamps = utc2et.(neid_timestamps) + + #NEID location + obs_lat = 31.9583 + obs_long = -111.5967 + alt = 2.097938 + + wavelength = 512 #must be in nanometers + + # set up paramaters for disk + N = 50 + Nt = length(time_stamps) + + # set up parameters for spectrum + lines = [6173.0] # array of line centers + depths = [0.6] # array of line depths + templates = ["FeI_6173"] # template data to use + variability = trues(length(lines)) # whether or not the bisectors should "dance" + blueshifts = zeros(length(lines)) # set convective blueshift value + resolution = 7e5 # spectral resolution + + # make the disk and spec composite type instances + disk = GRASS.DiskParamsEclipse(N=N, Nt=Nt, Nsubgrid=10) + spec = GRASS.SpecParams(lines=lines, depths=depths, variability=variability, + blueshifts=blueshifts, templates=templates, resolution=resolution) + + # actually synthesize the spectra + println(">>> Synthesizing on CPU...") + tstart = time() + lambdas_cpu, outspec_cpu = GRASS.synthesize_spectra_eclipse(spec, disk, obs_long, obs_lat, alt, wavelength, time_stamps, verbose=true, use_gpu=false) + tstop = time() + @printf(">>> Synthesis time --> %.3f seconds \n", tstop - tstart) + + #measure velocities + v_grid_cpu, ccf_cpu = GRASS.calc_ccf(lambdas_cpu, outspec_cpu, spec) + rvs_cpu, sigs_cpu = GRASS.calc_rvs_from_ccf(v_grid_cpu, ccf_cpu) +end + +if case == "Boulder" + boulder_timestamps = ["2023-10-14T13:25:37", "2023-10-14T13:27:01", "2023-10-14T13:28:23", "2023-10-14T13:29:42", "2023-10-14T13:31:08", "2023-10-14T13:32:25", "2023-10-14T13:33:49", "2023-10-14T13:35:10", "2023-10-14T13:36:33", "2023-10-14T13:37:56", "2023-10-14T13:39:18", "2023-10-14T13:40:37", "2023-10-14T13:42:01", "2023-10-14T13:43:22", "2023-10-14T13:44:46", "2023-10-14T13:46:09", "2023-10-14T13:47:26", "2023-10-14T13:48:50", "2023-10-14T13:50:14", "2023-10-14T13:51:38", "2023-10-14T13:52:57", "2023-10-14T13:53:55", "2023-10-14T13:59:00", "2023-10-14T13:59:41", "2023-10-14T14:03:04", "2023-10-14T14:03:20", "2023-10-14T14:05:15", "2023-10-14T14:06:34", "2023-10-14T14:12:22", "2023-10-14T14:13:27", "2023-10-14T14:14:48", "2023-10-14T14:16:12", "2023-10-14T14:17:34", "2023-10-14T14:18:56", "2023-10-14T14:20:20", "2023-10-14T14:21:44", "2023-10-14T14:23:02", "2023-10-14T14:24:24", "2023-10-14T14:25:45", "2023-10-14T14:27:10", "2023-10-14T14:28:32", "2023-10-14T14:29:50", "2023-10-14T14:31:13", "2023-10-14T14:32:34", "2023-10-14T14:33:59", "2023-10-14T14:35:21", "2023-10-14T14:36:18", "2023-10-14T15:38:31", "2023-10-14T15:39:34", "2023-10-14T15:40:55", "2023-10-14T15:42:19", "2023-10-14T15:43:37", "2023-10-14T15:44:42", "2023-10-14T15:46:30", "2023-10-14T15:47:48", "2023-10-14T15:49:10", "2023-10-14T15:50:31", "2023-10-14T15:51:53", "2023-10-14T15:53:14", "2023-10-14T15:54:37", "2023-10-14T15:55:59", "2023-10-14T15:57:21", "2023-10-14T15:58:40", "2023-10-14T16:00:04", "2023-10-14T16:01:28", "2023-10-14T16:02:49", "2023-10-14T16:04:11", "2023-10-14T16:05:32", "2023-10-14T16:06:54", "2023-10-14T16:08:18", "2023-10-14T16:09:39", "2023-10-14T16:11:01", "2023-10-14T16:12:25", "2023-10-14T16:13:46", "2023-10-14T16:15:08", "2023-10-14T16:16:27", "2023-10-14T16:17:50", "2023-10-14T16:19:14", "2023-10-14T16:20:36", "2023-10-14T16:21:57", "2023-10-14T16:23:19", "2023-10-14T16:24:40", "2023-10-14T16:26:04", "2023-10-14T16:27:26", "2023-10-14T16:28:47", "2023-10-14T16:30:09", "2023-10-14T16:31:32", "2023-10-14T16:32:54", "2023-10-14T16:34:16", "2023-10-14T16:35:37", "2023-10-14T16:36:58", "2023-10-14T16:39:52", "2023-10-14T16:41:05", "2023-10-14T16:42:32", "2023-10-14T16:43:51", "2023-10-14T16:45:12", "2023-10-14T16:46:23", "2023-10-14T16:48:03", "2023-10-14T16:49:17", "2023-10-14T16:50:42", "2023-10-14T16:51:58", "2023-10-14T16:53:24", "2023-10-14T16:54:45", "2023-10-14T16:56:06", "2023-10-14T16:57:31", "2023-10-14T16:58:53", "2023-10-14T17:00:13", "2023-10-14T17:01:35", "2023-10-14T17:02:56", "2023-10-14T17:04:20", "2023-10-14T17:05:42", "2023-10-14T17:07:03", "2023-10-14T17:08:27", "2023-10-14T17:09:49", "2023-10-14T17:11:10", "2023-10-14T17:12:32", "2023-10-14T17:13:53", "2023-10-14T17:15:17", "2023-10-14T17:16:39", "2023-10-14T17:18:00", "2023-10-14T17:19:21", "2023-10-14T17:20:43", "2023-10-14T17:22:07", "2023-10-14T17:23:28", "2023-10-14T17:24:50", "2023-10-14T17:26:12", "2023-10-14T17:27:33", "2023-10-14T17:28:41", "2023-10-14T18:41:52", "2023-10-14T18:42:46", "2023-10-14T18:44:08", "2023-10-14T18:45:29", "2023-10-14T18:46:50", "2023-10-14T18:48:12", "2023-10-14T18:49:36", "2023-10-14T18:50:39", "2023-10-14T18:55:41", "2023-10-14T18:56:25", "2023-10-14T18:57:51", "2023-10-14T18:59:09", "2023-10-14T19:00:33", "2023-10-14T19:01:54", "2023-10-14T19:03:13", "2023-10-14T19:04:37", "2023-10-14T20:37:30", "2023-10-14T23:07:01", "2023-10-14T23:07:58", "2023-10-14T23:09:18"] + #convert from utc to et as needed by SPICE + time_stamps = utc2et.(boulder_timestamps) + + #Boulder location + obs_lat = 39.995380 + obs_long = -105.262390 + alt = 1.6523 + + wavelength = 512 #must be in nanometers + + # set up paramaters for disk + N = 50 + Nt = length(time_stamps) + + # set up parameters for spectrum + lines = [6173.0] # array of line centers + depths = [0.6] # array of line depths + templates = ["FeI_6173"] # template data to use + variability = trues(length(lines)) # whether or not the bisectors should "dance" + blueshifts = zeros(length(lines)) # set convective blueshift value + resolution = 7e5 # spectral resolution + + # make the disk and spec composite type instances + disk = GRASS.DiskParamsEclipse(N=N, Nt=Nt, Nsubgrid=10) + spec = GRASS.SpecParams(lines=lines, depths=depths, variability=variability, + blueshifts=blueshifts, templates=templates, resolution=resolution) + + # actually synthesize the spectra + println(">>> Synthesizing on CPU...") + tstart = time() + lambdas_cpu, outspec_cpu = GRASS.synthesize_spectra_eclipse(spec, disk, obs_long, obs_lat, alt, wavelength, time_stamps, verbose=true, use_gpu=false) + tstop = time() + @printf(">>> Synthesis time --> %.3f seconds \n", tstop - tstart) + + #measure velocities + v_grid_cpu, ccf_cpu = GRASS.calc_ccf(lambdas_cpu, outspec_cpu, spec) + rvs_cpu, sigs_cpu = GRASS.calc_rvs_from_ccf(v_grid_cpu, ccf_cpu) +end + +if case == "EXPRES" + expres_timestamps = ["2023-10-14T14:10:59", "2023-10-14T14:14:06", "2023-10-14T14:17:04", "2023-10-14T14:19:54", "2023-10-14T14:23:59", "2023-10-14T14:26:38", "2023-10-14T14:29:11", "2023-10-14T14:31:41", "2023-10-14T14:34:09", "2023-10-14T14:36:33", "2023-10-14T14:38:56", "2023-10-14T14:41:16", "2023-10-14T14:43:33", "2023-10-14T14:45:49", "2023-10-14T14:49:17", "2023-10-14T14:51:29", "2023-10-14T14:53:39", "2023-10-14T14:55:48", "2023-10-14T14:57:56", "2023-10-14T15:00:03", "2023-10-14T15:02:09", "2023-10-14T15:04:15", "2023-10-14T15:06:19", "2023-10-14T15:08:22", "2023-10-14T15:11:40", "2023-10-14T15:13:41", "2023-10-14T15:15:43", "2023-10-14T15:17:45", "2023-10-14T15:19:45", "2023-10-14T15:21:48", "2023-10-14T15:23:51", "2023-10-14T15:25:56", "2023-10-14T15:28:00", "2023-10-14T15:30:06", "2023-10-14T15:32:14", "2023-10-14T15:34:25", "2023-10-14T15:36:37", "2023-10-14T15:38:53", "2023-10-14T15:41:09", "2023-10-14T15:43:29", "2023-10-14T15:45:53", "2023-10-14T15:48:23", "2023-10-14T15:51:00", "2023-10-14T15:53:43", "2023-10-14T15:57:47", "2023-10-14T16:00:54", "2023-10-14T16:04:16", "2023-10-14T16:07:56", "2023-10-14T16:11:48", "2023-10-14T16:15:39", "2023-10-14T16:19:29", "2023-10-14T16:23:20", "2023-10-14T16:27:13", "2023-10-14T16:31:06", "2023-10-14T16:35:00", "2023-10-14T16:38:52", "2023-10-14T16:42:43", "2023-10-14T16:46:34", "2023-10-14T16:50:25", "2023-10-14T16:54:17", "2023-10-14T16:57:59", "2023-10-14T17:01:24", "2023-10-14T17:04:31", "2023-10-14T17:07:27", "2023-10-14T17:10:11", "2023-10-14T17:12:47", "2023-10-14T17:15:16", "2023-10-14T17:17:38", "2023-10-14T17:19:55", "2023-10-14T17:22:07", "2023-10-14T17:24:15", "2023-10-14T17:26:20", "2023-10-14T17:28:19", "2023-10-14T17:30:16", "2023-10-14T17:34:02", "2023-10-14T17:37:09", "2023-10-14T17:40:07", "2023-10-14T17:43:00", "2023-10-14T17:45:50", "2023-10-14T17:48:35", "2023-10-14T17:51:20", "2023-10-14T17:53:58", "2023-10-14T17:56:37", "2023-10-14T17:59:18", "2023-10-14T18:01:52", "2023-10-14T18:05:29", "2023-10-14T18:08:02", "2023-10-14T18:10:35", "2023-10-14T18:13:16", "2023-10-14T18:15:46", "2023-10-14T18:18:17", "2023-10-14T18:20:47", "2023-10-14T18:23:22", "2023-10-14T18:25:54", "2023-10-14T18:28:25", "2023-10-14T18:30:52", "2023-10-14T18:33:32", "2023-10-14T18:37:00", "2023-10-14T18:39:30", "2023-10-14T18:41:55", "2023-10-14T18:44:21", "2023-10-14T18:46:46", "2023-10-14T18:49:15", "2023-10-14T18:51:40", "2023-10-14T18:54:04", "2023-10-14T18:56:29", "2023-10-14T18:58:54", "2023-10-14T19:01:19", "2023-10-14T19:03:43", "2023-10-14T19:06:07", "2023-10-14T19:09:34", "2023-10-14T19:11:58", "2023-10-14T19:14:20", "2023-10-14T19:16:42", "2023-10-14T19:19:05", "2023-10-14T19:21:36", "2023-10-14T19:23:58", "2023-10-14T19:26:24", "2023-10-14T19:28:46", "2023-10-14T19:31:10", "2023-10-14T19:33:32", "2023-10-14T19:35:57", "2023-10-14T19:38:23", "2023-10-14T19:41:47", "2023-10-14T19:44:09", "2023-10-14T19:46:29", "2023-10-14T19:48:51", "2023-10-14T19:51:13", "2023-10-14T19:53:36", "2023-10-14T19:56:04", "2023-10-14T19:58:25", "2023-10-14T20:00:45", "2023-10-14T20:03:06", "2023-10-14T20:05:34", "2023-10-14T20:07:54", "2023-10-14T20:10:15", "2023-10-14T20:13:40", "2023-10-14T20:16:00", "2023-10-14T20:18:23", "2023-10-14T20:20:44", "2023-10-14T20:23:05", "2023-10-14T20:25:26", "2023-10-14T20:27:56", "2023-10-14T20:30:26", "2023-10-14T20:32:50", "2023-10-14T20:35:11", "2023-10-14T20:37:33", "2023-10-14T20:39:59", "2023-10-14T20:42:25", "2023-10-14T20:45:52", "2023-10-14T20:48:12", "2023-10-14T20:50:34", "2023-10-14T20:52:57", "2023-10-14T20:55:23", "2023-10-14T20:57:50", "2023-10-14T21:00:11", "2023-10-14T21:02:35", "2023-10-14T21:04:58", "2023-10-14T21:07:19", "2023-10-14T21:09:42", "2023-10-14T21:12:04", "2023-10-14T21:14:26", "2023-10-14T21:17:55", "2023-10-14T21:20:20", "2023-10-14T21:22:44", "2023-10-14T21:25:08", "2023-10-14T21:27:31", "2023-10-14T21:30:00", "2023-10-14T21:32:23", "2023-10-14T21:34:51", "2023-10-14T21:37:15", "2023-10-14T21:39:40", "2023-10-14T21:42:06", "2023-10-14T21:44:31", "2023-10-14T21:46:57", "2023-10-14T21:50:24", "2023-10-14T21:52:51", "2023-10-14T21:55:17", "2023-10-14T21:57:44", "2023-10-14T22:00:13", "2023-10-14T22:02:42", "2023-10-14T22:05:12", "2023-10-14T22:07:41", "2023-10-14T22:10:10", "2023-10-14T22:12:40", "2023-10-14T22:15:11", "2023-10-14T22:17:43", "2023-10-14T22:20:15", "2023-10-14T22:23:59", "2023-10-14T22:26:36", "2023-10-14T22:29:19", "2023-10-14T22:31:56", "2023-10-14T22:34:31", "2023-10-14T22:37:06", "2023-10-14T22:39:42", "2023-10-14T22:42:18", "2023-10-14T22:44:54", "2023-10-14T22:47:33", "2023-10-14T22:50:16", "2023-10-14T22:52:56", "2023-10-14T22:56:41", "2023-10-14T22:59:11"] + #convert from utc to et as needed by SPICE + time_stamps = utc2et.(expres_timestamps) + + #EXPRES location + obs_lat = 34.744444 + obs_long = -111.421944 + alt = 2.359152 + + wavelength = 512 #must be in nanometers + + # set up paramaters for disk + N = 50 + Nt = length(time_stamps) + + # set up parameters for spectrum + lines = [6173.0] # array of line centers + depths = [0.6] # array of line depths + templates = ["FeI_6173"] # template data to use + variability = trues(length(lines)) # whether or not the bisectors should "dance" + blueshifts = zeros(length(lines)) # set convective blueshift value + resolution = 7e5 # spectral resolution + + # make the disk and spec composite type instances + disk = GRASS.DiskParamsEclipse(N=N, Nt=Nt, Nsubgrid=10) + spec = GRASS.SpecParams(lines=lines, depths=depths, variability=variability, + blueshifts=blueshifts, templates=templates, resolution=resolution) + + # actually synthesize the spectra + println(">>> Synthesizing on CPU...") + tstart = time() + lambdas_cpu, outspec_cpu = GRASS.synthesize_spectra_eclipse(spec, disk, obs_long, obs_lat, alt, wavelength, time_stamps, verbose=true, use_gpu=false) + tstop = time() + @printf(">>> Synthesis time --> %.3f seconds \n", tstop - tstart) + + #measure velocities + v_grid_cpu, ccf_cpu = GRASS.calc_ccf(lambdas_cpu, outspec_cpu, spec) + rvs_cpu, sigs_cpu = GRASS.calc_rvs_from_ccf(v_grid_cpu, ccf_cpu) +end + +if case == "Gottingen" + reiners_50 = ["2015-03-20T07:08:47.200000", "2015-03-20T07:10:35.800000", "2015-03-20T07:12:24.300000", "2015-03-20T07:14:12.900000", "2015-03-20T07:16:01.500000", "2015-03-20T07:17:50.300000", "2015-03-20T07:19:39.700000", "2015-03-20T07:21:28.500000", "2015-03-20T07:23:17.400000", "2015-03-20T07:25:06.500000", "2015-03-20T07:26:55.500000", "2015-03-20T07:28:43.800000", "2015-03-20T07:30:32.500000", "2015-03-20T07:32:20.700000", "2015-03-20T07:34:09.200000", "2015-03-20T07:35:59.500000", "2015-03-20T07:37:48.000000", "2015-03-20T07:39:36.100000", "2015-03-20T07:41:24.600000", "2015-03-20T07:43:12.800000", "2015-03-20T07:45:01.500000", "2015-03-20T07:46:50.100000", "2015-03-20T07:48:38.800000", "2015-03-20T07:50:27.100000", "2015-03-20T07:52:15.300000", "2015-03-20T07:54:03.900000", "2015-03-20T07:55:52.300000", "2015-03-20T07:57:40.700000", "2015-03-20T07:59:29.000000", "2015-03-20T08:01:17.200000", "2015-03-20T08:03:05.700000", "2015-03-20T08:04:54.000000", "2015-03-20T08:06:43.000000", "2015-03-20T08:08:31.400000", "2015-03-20T08:10:20.000000", "2015-03-20T08:12:08.500000", "2015-03-20T08:13:57.100000", "2015-03-20T08:15:45.300000", "2015-03-20T08:17:33.700000", "2015-03-20T08:19:22.100000", "2015-03-20T08:21:10.400000", "2015-03-20T08:22:59.400000", "2015-03-20T08:24:47.700000", "2015-03-20T08:26:36.100000", "2015-03-20T08:28:24.700000", "2015-03-20T08:30:13.000000", "2015-03-20T08:32:01.300000", "2015-03-20T08:33:49.500000", "2015-03-20T08:35:37.900000", "2015-03-20T08:37:26.300000", "2015-03-20T08:39:44.500000", "2015-03-20T08:41:33.000000", "2015-03-20T08:43:21.400000", "2015-03-20T08:45:09.900000", "2015-03-20T08:46:58.500000", "2015-03-20T08:48:46.800000", "2015-03-20T08:50:35.500000", "2015-03-20T08:52:24.000000", "2015-03-20T08:54:12.900000", "2015-03-20T08:56:01.500000", "2015-03-20T08:57:49.600000", "2015-03-20T08:59:37.900000", "2015-03-20T09:01:26.100000", "2015-03-20T09:03:14.800000", "2015-03-20T09:05:03.100000", "2015-03-20T09:06:51.700000", "2015-03-20T09:08:40.200000", "2015-03-20T09:10:28.700000", "2015-03-20T09:12:17.100000", "2015-03-20T09:14:05.500000", "2015-03-20T09:15:54.000000", "2015-03-20T09:17:43.100000", "2015-03-20T09:19:32.100000", "2015-03-20T09:21:20.900000", "2015-03-20T09:23:09.700000", "2015-03-20T09:24:58.500000", "2015-03-20T09:26:47.300000", "2015-03-20T09:28:35.900000", "2015-03-20T09:30:24.700000", "2015-03-20T09:32:13.100000", "2015-03-20T09:34:01.500000", "2015-03-20T09:35:49.900000", "2015-03-20T09:37:38.400000", "2015-03-20T09:39:27.400000", "2015-03-20T09:41:16.300000", "2015-03-20T09:43:05.000000", "2015-03-20T09:44:53.800000", "2015-03-20T09:46:42.200000", "2015-03-20T09:48:30.700000", "2015-03-20T09:50:19.700000", "2015-03-20T09:52:08.400000", "2015-03-20T09:53:57.500000", "2015-03-20T09:55:45.900000", "2015-03-20T09:57:34.900000", "2015-03-20T09:59:23.300000", "2015-03-20T10:01:11.800000", "2015-03-20T10:03:00.100000", "2015-03-20T10:04:48.600000", "2015-03-20T10:06:37.400000", "2015-03-20T10:08:26.200000", "2015-03-20T10:10:44.500000", "2015-03-20T10:12:33.900000", "2015-03-20T10:14:23.600000", "2015-03-20T10:16:12.600000", "2015-03-20T10:18:01.700000", "2015-03-20T10:19:50.900000", "2015-03-20T10:21:39.900000", "2015-03-20T10:23:28.900000", "2015-03-20T10:25:17.900000", "2015-03-20T10:27:07.000000", "2015-03-20T10:28:57.100000", "2015-03-20T10:30:46.100000", "2015-03-20T10:32:35.100000", "2015-03-20T10:34:24.000000", "2015-03-20T10:36:12.900000", "2015-03-20T10:38:02.000000", "2015-03-20T10:39:51.000000", "2015-03-20T10:41:39.900000", "2015-03-20T10:43:28.700000", "2015-03-20T10:45:17.600000", "2015-03-20T10:47:06.800000", "2015-03-20T10:48:55.800000", "2015-03-20T10:50:44.900000", "2015-03-20T10:52:33.600000", "2015-03-20T10:54:22.700000", "2015-03-20T10:56:11.900000", "2015-03-20T10:58:00.800000", "2015-03-20T10:59:49.700000", "2015-03-20T11:01:39.800000", "2015-03-20T11:03:28.600000", "2015-03-20T11:05:17.700000", "2015-03-20T11:07:06.800000", "2015-03-20T11:08:55.700000", "2015-03-20T11:10:44.600000", "2015-03-20T11:12:33.600000", "2015-03-20T11:14:23.100000", "2015-03-20T11:16:12.000000", "2015-03-20T11:18:00.900000", "2015-03-20T11:19:49.900000", "2015-03-20T11:21:38.700000", "2015-03-20T11:23:27.700000", "2015-03-20T11:25:16.700000", "2015-03-20T11:27:05.700000", "2015-03-20T11:28:54.300000", "2015-03-20T11:30:43.000000", "2015-03-20T11:32:31.700000", "2015-03-20T11:34:20.300000", "2015-03-20T11:36:09.000000", "2015-03-20T11:37:57.700000", "2015-03-20T11:39:46.900000", "2015-03-20T11:49:27.500000", "2015-03-20T11:51:16.600000", "2015-03-20T11:53:05.600000", "2015-03-20T11:54:54.200000", "2015-03-20T11:56:43.100000", "2015-03-20T11:58:31.800000", "2015-03-20T12:00:20.500000", "2015-03-20T12:02:09.100000", "2015-03-20T12:03:57.600000"] + #convert from utc to et as needed by SPICE + time_stamps = utc2et.(reiners_50) + + #Gottingen location + obs_lat = 51.560583 + obs_long = 9.944333 + alt = 0.201 + + wavelength = 512 #must be in nanometers + + # set up paramaters for disk + N = 50 + Nt = length(time_stamps) + + # set up parameters for spectrum + lines = [6173.0] # array of line centers + depths = [0.6] # array of line depths + templates = ["FeI_6173"] # template data to use + variability = trues(length(lines)) # whether or not the bisectors should "dance" + blueshifts = zeros(length(lines)) # set convective blueshift value + resolution = 7e5 # spectral resolution + + # make the disk and spec composite type instances + disk = GRASS.DiskParamsEclipse(N=N, Nt=Nt, Nsubgrid=10) + spec = GRASS.SpecParams(lines=lines, depths=depths, variability=variability, + blueshifts=blueshifts, templates=templates, resolution=resolution) + + # actually synthesize the spectra + println(">>> Synthesizing on CPU...") + tstart = time() + lambdas_cpu, outspec_cpu = GRASS.synthesize_spectra_eclipse(spec, disk, obs_long, obs_lat, alt, wavelength, time_stamps, verbose=true, use_gpu=false) + tstop = time() + @printf(">>> Synthesis time --> %.3f seconds \n", tstop - tstart) + + #measure velocities + v_grid_cpu, ccf_cpu = GRASS.calc_ccf(lambdas_cpu, outspec_cpu, spec) + rvs_cpu, sigs_cpu = GRASS.calc_rvs_from_ccf(v_grid_cpu, ccf_cpu) + + print(rvs) +end diff --git a/src/GRASS.jl b/src/GRASS.jl index 239bed97..211c20ac 100644 --- a/src/GRASS.jl +++ b/src/GRASS.jl @@ -44,6 +44,14 @@ earth_radius_pole = bodvrd("EARTH", "RADII")[3] sun_radius = bodvrd("SUN","RADII")[1] moon_radius = bodvrd("MOON", "RADII")[1] +lambda_nm = [303.327, 310.843, 320.468, 329.897, 349.947, 365.875, 374.086, 390.915, 401.970, 416.319, 427.930, 443.885, 445.125, 457.345, 477.427, 492.905, 519.930, 541.76, 559.95, 579.88, 610.975, 640.97, 669.4, 700.875, 748.71, 811.76, 869.6, 948.85, 1046.6, 1098.95] +a0 = [0.08011, 0.08160, 0.08833, 0.09188, 0.11012, 0.12828, 0.12579, 0.12995, 0.12323, 0.12814, 0.14249, 0.16220, 0.15248, 0.16604, 0.19571, 0.20924, 0.23695, 0.26073, 0.26892, 0.28392, 0.30854, 0.33644, 0.34685, 0.37885, 0.40627, 0.42977, 0.45396, 0.47855, 0.49870, 0.51149] +a1 = [0.70695, 0.71609, 0.77285, 0.92459, 1.02168, 1.04969, 0.85402, 0.91836, 1.08648, 1.19947, 1.28796, 1.24893, 1.38517, 1.38544, 1.30551, 1.30798, 1.29927, 1.27428, 1.34319, 1.36896, 1.3662, 1.30590, 1.37539, 1.25553, 1.22842, 1.25182, 1.25101, 1.19813, 1.21429, 1.19354] +a2 = [0.4991, 0.69685, 0.65382, 0.19604, -0.10924, 0.17482, 0.54601, -0.07566, -0.43974, -0.84407, -1.19564, -0.92165, -1.49615, -1.52275, -1.25845, -1.20411, -1.28034, -1.30352, -1.58427, -1.75998, -1.83572, -1.79238, -2.04425, -1.70908, -1.67877, -1.85164, -2.02958, -1.86296, -2.06976, -2.00174] +a3 = [-0.31080, -0.87703, -1.04647, -0.39546, -0.00055, -1.13371, -1.15048, 0.19149, 0.45912, 1.07201, 1.68603, 0.89978, 1.99886, 2.00232, 1.50626, 1.21505, 1.37760, 1.47085, 1.91271, 2.22154, 2.33221, 2.4504, 2.70493, 2.19647, 2.05535, 2.31949, 2.7541, 2.36939, 2.80703, 2.66936] +a4 = [-0.02177, 0.47008, 0.72921, 0.23599, -0.08688, 1.23882, 0.88928, -0.28712, -0.32759, -0.79537, -1.36658, -0.50148, -1.48155, -1.45969, -1.05472, -0.67196, -0.85054, -0.96618, -1.3135, -1.56074, -1.63082, -1.89979, -1.9429, -1.59554, -1.39972, -1.59101, -2.02287, -1.64367, -2.05247, -1.94981] +a5 = [0.04642, -0.0876, -0.19775, -0.05303, 0.06487, -0.4599, -0.26462, 0.12298, 0.0985, 0.23982, 0.44572, 0.1122, 0.44119, 0.42864, 0.30570, 0.14381, 0.21706, 0.26384, 0.37295, 0.4463, 0.45959, 0.59943, 0.55999, 0.47378, 0.38845, 0.44155, 0.59338, 0.46056, 0.60221, 0.57715] + # configure directories include("config.jl") diff --git a/src/convenience_eclipse.jl b/src/convenience_eclipse.jl index af9fab21..d6e7e7d0 100644 --- a/src/convenience_eclipse.jl +++ b/src/convenience_eclipse.jl @@ -7,7 +7,7 @@ Synthesize spectra given parameters in `spec` and `disk` instances. - `spec::SpecParams`: SpecParams instance - `disk::DiskParams`: DiskParams instance """ -function synthesize_spectra_eclipse(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, obs_long, obs_lat, alt, time_stamps; +function synthesize_spectra_eclipse(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, obs_long, obs_lat, alt, wavelength, time_stamps; seed_rng::Bool=false, verbose::Bool=true, use_gpu::Bool=false, precision::DataType=Float64, skip_times::BitVector=falses(disk.Nt)) where T<:AF @@ -15,12 +15,12 @@ function synthesize_spectra_eclipse(spec::SpecParams{T}, disk::DiskParamsEclipse if use_gpu return synth_Eclipse_gpu(spec, disk, seed_rng, verbose, precision, skip_times) else - return synth_Eclipse_cpu(spec, disk, seed_rng, verbose, skip_times, obs_long, obs_lat, alt, time_stamps) + return synth_Eclipse_cpu(spec, disk, seed_rng, verbose, skip_times, obs_long, obs_lat, alt, time_stamps, wavelength) end end function synth_Eclipse_cpu(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, seed_rng::Bool, - verbose::Bool, skip_times::BitVector, obs_long, obs_lat, alt, time_stamps) where T<:AF + verbose::Bool, skip_times::BitVector, obs_long, obs_lat, alt, time_stamps, wavelength) where T<:AF # parse out dimensions for memory allocation N = disk.N @@ -58,7 +58,7 @@ function synth_Eclipse_cpu(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, seed end # run the simulation and multiply flux by this spectrum - disk_sim_eclipse(spec_temp, disk, soldata, wsp, prof, flux, tloop, tloop_init, templates, idx, obs_long, obs_lat, alt, time_stamps, + disk_sim_eclipse(spec_temp, disk, soldata, wsp, prof, flux, tloop, tloop_init, templates, idx, obs_long, obs_lat, alt, time_stamps, wavelength, skip_times=skip_times, verbose=verbose) end return spec.lambdas, flux diff --git a/src/disk_sim_eclipse.jl b/src/disk_sim_eclipse.jl index 205b15af..4a794131 100644 --- a/src/disk_sim_eclipse.jl +++ b/src/disk_sim_eclipse.jl @@ -1,13 +1,13 @@ function disk_sim_eclipse(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, soldata::SolarData{T}, wsp::SynthWorkspaceEclipse{T}, prof::AA{T,1}, flux::AA{T,2}, - tloop, tloop_init, templates, idx, obs_long, obs_lat, alt, time_stamps; verbose::Bool=true, + tloop, tloop_init, templates, idx, obs_long, obs_lat, alt, time_stamps, wavelength; verbose::Bool=true, skip_times::BitVector=falses(disk.Nt)) where T<:AF # loop over time for t in 1:disk.Nt #compute geometry for timestamp - GRASS.eclipse_compute_quantities!(disk, time_stamps[t], obs_long, obs_lat, alt, wsp.ϕc, wsp.θc, wsp.μs, wsp.ld, wsp.dA, wsp.xyz, wsp.wts, wsp.z_rot, wsp.ax_codes) + GRASS.eclipse_compute_quantities!(disk, time_stamps[t], obs_long, obs_lat, alt, wavelength, wsp.ϕc, wsp.θc, wsp.μs, wsp.ld, wsp.dA, wsp.xyz, wsp.wts, wsp.z_rot, wsp.ax_codes) # get conv. blueshift and keys from input data GRASS.get_keys_and_cbs_eclispe!(wsp, soldata) diff --git a/src/eclipse_comp.jl b/src/eclipse_comp.jl index e09654dc..e27e095b 100644 --- a/src/eclipse_comp.jl +++ b/src/eclipse_comp.jl @@ -1,5 +1,5 @@ function eclipse_compute_quantities!(disk::DiskParamsEclipse{T}, epoch::T, obs_long::T, - obs_lat::T, alt::T, ϕc::AA{T,2}, θc::AA{T,2}, + obs_lat::T, alt::T, wavelength::T, ϕc::AA{T,2}, θc::AA{T,2}, μs::AA{T,2}, ld::AA{T,2}, dA::AA{T,2}, xyz::AA{T,3}, wts::AA{T,2}, z_rot::AA{T,2}, ax_codes::AA{Int64, 2}) where T<:AF @@ -140,7 +140,7 @@ function eclipse_compute_quantities!(disk::DiskParamsEclipse{T}, epoch::T, obs_l end # calc limb darkening - ld_sub = map(x -> quad_limb_darkening_eclipse(x), mu_grid) + ld_sub = map(x -> quad_limb_darkening_eclipse(x, wavelength), mu_grid) # calculate area element of tile dϕ = step(ϕe_sub) diff --git a/src/star_physics.jl b/src/star_physics.jl index 09fd5cde..a84e4542 100644 --- a/src/star_physics.jl +++ b/src/star_physics.jl @@ -23,9 +23,13 @@ function width_thermal(; λ::T1=1.0, M::T1=1.0, T::T1=5778.0, v_turb::T1=0.0) wh return sqrt((2.0*kB/mH) * (T/M) + v_turb^2) * (λ/c) end -function quad_limb_darkening_eclipse(μ::T) where T<:AF +function quad_limb_darkening_eclipse(μ::T, wavelength::T) where T<:AF μ < zero(T) && return 0.0 - return 0.28392 + 1.36896*μ - 1.75998*μ^2 + 2.22154*μ^3 - 1.56074*μ^4 + 0.44630*μ^5 + + index = findmin(x->abs(x-wavelength), lambda_nm)[2] + + return a0[index] + a1[index]*μ - a2[index]*μ^2 + a3[index]*μ^3 - a4[index]*μ^4 + a5[index]*μ^5 + #return 0.28392 + 1.36896*μ - 1.75998*μ^2 + 2.22154*μ^3 - 1.56074*μ^4 + 0.44630*μ^5 end function quad_limb_darkening(μ::T, u1::T, u2::T) where T<:AF