diff --git a/example_spec.jl b/example_spec.jl index bdbd2e6..1761b19 100644 --- a/example_spec.jl +++ b/example_spec.jl @@ -157,6 +157,11 @@ if case == "EXPRES" 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" + #no CB model + #variability = falses + #fixed_bisector = true + #extra_z = 0 + blueshifts = zeros(length(lines)) # set convective blueshift value resolution = 7e5 # spectral resolution @@ -168,13 +173,15 @@ if case == "EXPRES" # 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, lines[1]/10.0, time_stamps, verbose=true, use_gpu=false) + lambdas_cpu, outspec_cpu = GRASS.synthesize_spectra_eclipse(spec, disk, obs_long, obs_lat, alt, lines ./ 10.0, time_stamps, verbose=true, use_gpu=false, fixed_bisector=true) 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_cpu) end if case == "Gottingen" @@ -213,6 +220,6 @@ if case == "Gottingen" @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) + GRASS.calc_ccf(lambdas_cpu, outspec_cpu, spec) + # rvs_cpu, sigs_cpu = GRASS.calc_rvs_from_ccf(v_grid_cpu, ccf_cpu) end diff --git a/express_line.png b/express_line.png new file mode 100644 index 0000000..e89218e Binary files /dev/null and b/express_line.png differ diff --git a/express_line_fixed.png b/express_line_fixed.png new file mode 100644 index 0000000..ee62a2b Binary files /dev/null and b/express_line_fixed.png differ diff --git a/line.png b/line.png new file mode 100644 index 0000000..00f6649 Binary files /dev/null and b/line.png differ diff --git a/rm.png b/rm.png new file mode 100644 index 0000000..411b8c4 Binary files /dev/null and b/rm.png differ diff --git a/src/convenience_eclipse.jl b/src/convenience_eclipse.jl index 59c3bc1..8ba11d2 100644 --- a/src/convenience_eclipse.jl +++ b/src/convenience_eclipse.jl @@ -9,18 +9,18 @@ Synthesize spectra given parameters in `spec` and `disk` instances. """ 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, + use_gpu::Bool=false, precision::DataType=Float64, fixed_bisector::Bool=false, skip_times::BitVector=falses(disk.Nt)) where T<:AF # call appropriate simulation function on cpu or gpu if use_gpu - return synth_Eclipse_gpu(spec, disk, seed_rng, verbose, precision, skip_times, obs_long, obs_lat, alt, time_stamps, wavelength) + return synth_Eclipse_gpu(spec, disk, seed_rng, verbose, precision, skip_times, obs_long, obs_lat, alt, time_stamps, wavelength, fixed_bisector) else - return synth_Eclipse_cpu(spec, disk, seed_rng, verbose, skip_times, obs_long, obs_lat, alt, time_stamps, wavelength) + return synth_Eclipse_cpu(spec, disk, seed_rng, verbose, skip_times, obs_long, obs_lat, alt, time_stamps, wavelength, fixed_bisector) 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, wavelength) where T<:AF + verbose::Bool, skip_times::BitVector, obs_long, obs_lat, alt, time_stamps, wavelength, fixed_bisector::Bool) where T<:AF # parse out dimensions for memory allocation N = disk.N @@ -51,7 +51,7 @@ function synth_Eclipse_cpu(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, seed if verbose println("\t>>> Template: " * splitdir(file)[end]) end - soldata = SolarData(fname=file) + soldata = SolarData(fname=file, fixed_bisector=fixed_bisector) # re-seed the rng if seed_rng @@ -66,7 +66,7 @@ function synth_Eclipse_cpu(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, seed end function synth_Eclipse_gpu(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, seed_rng::Bool, - verbose::Bool, precision::DataType, skip_times::BitVector, obs_long, obs_lat, alt, time_stamps, wavelength) where T<:AF + verbose::Bool, precision::DataType, skip_times::BitVector, obs_long, obs_lat, alt, time_stamps, wavelength, fixed_bisector::Bool) where T<:AF # make sure there is actually a GPU to use @assert CUDA.functional() @@ -98,9 +98,15 @@ function synth_Eclipse_gpu(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, seed if verbose println("\t>>> Template: " * splitdir(file)[end]) end - soldata_cpu = SolarData(fname=file) + soldata_cpu = SolarData(fname=file, fixed_bisector=fixed_bisector) soldata = GPUSolarData(soldata_cpu, precision=precision) +<<<<<<< HEAD +======= + # # get conv. blueshift and keys from input data + # get_keys_and_cbs_gpu!(gpu_allocs, soldata) + +>>>>>>> 54cdc15f7b3705708bc2a47744517551b5599e2d # run the simulation and multiply flux by this spectrum disk_sim_eclipse_gpu(spec_temp, disk, soldata, gpu_allocs, flux, templates, idx, diff --git a/src/disk_sim_eclipse.jl b/src/disk_sim_eclipse.jl index 89ad04b..385cc2b 100644 --- a/src/disk_sim_eclipse.jl +++ b/src/disk_sim_eclipse.jl @@ -65,6 +65,7 @@ function disk_sim_eclipse(spec::SpecParams{T}, disk::DiskParamsEclipse{T}, solda # get amount of convective blueshift needed extra_z = spec.conv_blueshifts[l] - z_cbs_avg + #extra_z = 0.0 # spec.conv_blueshifts[l] - z_cbs_avg # get shifted line center λΔD = spec.lines[l] diff --git a/src/gpu/gpu_precomps_eclipse.jl b/src/gpu/gpu_precomps_eclipse.jl index b35e991..8efa484 100644 --- a/src/gpu/gpu_precomps_eclipse.jl +++ b/src/gpu/gpu_precomps_eclipse.jl @@ -241,7 +241,7 @@ function calc_eclipse_quantities_gpu!(wavelength, μs, z_rot, ax_codes, #calculate distance n2 = CUDA.sqrt(OM_bary[1]^2.0 + OM_bary[2]^2.0 + OM_bary[3]^2.0) - d2 = (OM_bary[1] * OP_bary_x + OM_bary[2] * OP_bary_y + OM_bary[3] * OP_bary_z) / (n2 * n1) + d2 = acos((OM_bary[1] * OP_bary_x + OM_bary[2] * OP_bary_y + OM_bary[3] * OP_bary_z) / (n2 * n1)) if (d2 < atan(moon_radius/n2)) continue end diff --git a/src/gpu/gpu_sim_eclipse.jl b/src/gpu/gpu_sim_eclipse.jl index 0ad66bb..163560f 100644 --- a/src/gpu/gpu_sim_eclipse.jl +++ b/src/gpu/gpu_sim_eclipse.jl @@ -72,11 +72,6 @@ function disk_sim_eclipse_gpu(spec::SpecParams{T1}, disk::DiskParamsEclipse{T1}, @cusync @cuda threads=threads1 blocks=blocks1 generate_tloop_gpu!(tloop, dat_idx, lenall_gpu) end - # plt.imshow(Array(gpu_allocs.ax_codes)) - # plt.colorbar() - # plt.show() - # break - # don't synthesize spectrum if skip_times is true, but iterate t index if skip_times[t] @cusync @captured @cuda threads=threads1 blocks=blocks1 iterate_tloop_gpu!(tloop, dat_idx, lenall_gpu) @@ -113,9 +108,9 @@ function disk_sim_eclipse_gpu(spec::SpecParams{T1}, disk::DiskParamsEclipse{T1}, widall_gpu_loop, allwavs, allints) # do the line synthesis, interp back onto wavelength grid - # @cusync @cuda threads=threads4 blocks=blocks4 line_profile_gpu!(prof, μs, ld[:,:,l], dA, λs, allwavs, allints) + @cusync @cuda threads=threads4 blocks=blocks4 line_profile_gpu!(prof, μs, ld[:,:,l], dA, λs, allwavs, allints) - @cusync @cuda threads=threads4 blocks=blocks4 line_profile_gpu!(prof, μs, ld, dA, λs, allwavs, allints) + #@cusync @cuda threads=threads4 blocks=blocks4 line_profile_gpu!(prof, μs, ld, dA, λs, allwavs, allints) # copy data from GPU to CPU @cusync @cuda threads=threads5 blocks=blocks5 apply_line!(t, prof, flux, sum_wts) diff --git a/src/gpu/gpu_synthesis.jl b/src/gpu/gpu_synthesis.jl index eec3ac8..ed64767 100644 --- a/src/gpu/gpu_synthesis.jl +++ b/src/gpu/gpu_synthesis.jl @@ -178,9 +178,9 @@ function line_profile_gpu!(prof, μs, ld, dA, λs, allwavs, allints) # loop over wavelengths for j in idy:sdy:CUDA.length(λs) if ((λs[j] < CUDA.first(allwavs_i)) || (λs[j] > CUDA.last(allwavs_i))) - @inbounds CUDA.@atomic prof[j] += dA[m,n] * ld[m,n,1] + @inbounds CUDA.@atomic prof[j] += dA[m,n] * ld[m,n] else - @inbounds CUDA.@atomic prof[j] += itp(λs[j]) * dA[m,n] * ld[m,n,1] + @inbounds CUDA.@atomic prof[j] += itp(λs[j]) * dA[m,n] * ld[m,n] end end end diff --git a/src/velocities.jl b/src/velocities.jl index 5c76bed..354b4a0 100644 --- a/src/velocities.jl +++ b/src/velocities.jl @@ -105,12 +105,13 @@ function calc_ccf(λs::AA{T1,1}, flux::AA{T1,2}, ccf[i,j] = ccf_plan.allow_nans ? nansum(proj_flux) : sum(proj_flux) end end + # print(ccf) - # normalize if normalize==true - if normalize - ccf ./= maximum(ccf) - end - return v_grid, ccf + # # normalize if normalize==true + # if normalize + # ccf ./= maximum(ccf) + # end + # return v_grid, ccf end function calc_ccf!(v_grid::AA{T1,1}, projection::AA{T1,2}, proj_flux::AA{T1,1},