Skip to content

Commit

Permalink
fix artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
amylu00 committed Dec 5, 2024
1 parent 7081d1a commit 954fb07
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[AIDA_ice_nucleation]
git-tree-sha1 = "4a298d3558691217adb253b4053611931d62c5c2"
git-tree-sha1 = "91a1a51fb6ebb54282e65de1a2aace5e4ef1c45a"
lazy = true

[[AIDA_ice_nucleation.download]]
sha256 = "b513219566a3d1125acf1515f0d80b5d212f2bb78acead15137dfff47b503f9d"
sha256 = "df37e510212e328c30f052938537ac29dd217206c266c501c2fb797faa3f4c8a"
url = "https://caltech.box.com/shared/static/imo0pyr6o0m9txu8racztmt7lz5n9xf1.gz"
24 changes: 11 additions & 13 deletions papers/ice_nucleation_2024/AIDA_calibrations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include(joinpath(pkgdir(CM), "papers", "ice_nucleation_2024", "calibration.jl"))
function unpack_data(data_file_name)

file_path = CM.ArtifactCalling.AIDA_ice_nucleation(data_file_name)
return DelimitedFiles.readdlm(file_path, skipstart = 125)
return DelimitedFiles.readdlm(file_path, skipstart = 126)
end
function grab_data(unpacked_data)

Expand All @@ -33,13 +33,11 @@ moving_average(data, n) =
[sum(@view data[i:(i + n)]) / n for i in 1:(length(data) - n)]

# Defining data names, start/end times, etc.
# data_file_names = ["in05_17_aida.edf", "in05_18_aida.edf", "in05_19_aida.edf", "in07_01_aida.edf", "in07_19_aida.edf"]
# plot_names = ["IN0517", "IN0518", "IN0519", "IN0701", "IN0719"]
data_file_names = ["in05_17_aida.edf", "in05_18_aida.edf", "in05_19_aida.edf"]
plot_names = ["IN0517", "IN0518", "IN0519"]
end_sim = 25 # Loss func looks at last end_sim timesteps only
start_time_index_list = [195, 180, 80, 50, 35] .+ 100 # AIDA time starts at -100 seconds. Add freezing onset as needed.
end_time_index_list = [290, 290, 170, 800, 800] .+ 100 # approximate time freezing stops
start_time_list = [195, 180, 80, 50, 35] # freezing onset
end_time_list = [290, 290, 170, 800, 800] # approximate time freezing stops
moving_average_n = 20 # average every n points
updrafts = [FT(1.5), FT(1.4), FT(5), FT(1.5), FT(1.5)] # updrafts matching AIDA cooling rate

Expand All @@ -55,23 +53,23 @@ for (exp_index, data_file_name) in enumerate(data_file_names)
### Unpacking experiment-specific variables.
plot_name = plot_names[exp_index]
w = updrafts[exp_index]
start_time_index = start_time_index_list[exp_index]
start_time = start_time_index - 100
end_time_index = end_time_index_list[exp_index]
end_time = end_time_index - 100
start_time = start_time_list[exp_index]
start_time_index = start_time .+ 100
end_time = end_time_list[exp_index]
end_time_index = end_time .+ 100

## Moving average to smooth data.
moving_average_start_index = Int32(start_time_index + (moving_average_n / 2))
moving_average_end_index = Int32(end_time_index - (moving_average_n / 2))
t_max = moving_average_end_index - moving_average_start_index
# (end_time - (moving_average_n / 2)) - # AIDA time starts at -100 seconds (t = 0 at index 101)
# (start_time + (moving_average_n / 2 - 1)) # duration of simulation

### Check for data file in AIDA_data folder.
### Check for and grab data in AIDA_data folder.
chamber_data = unpack_data(data_file_name)
AIDA_data = grab_data(chamber_data)
(; AIDA_t_profile, AIDA_T_profile, AIDA_P_profile, AIDA_ICNC, AIDA_e) = AIDA_data
t_profile = AIDA_t_profile[moving_average_start_index:moving_average_end_index] .- moving_average_start_index .+ 100
t_profile = AIDA_t_profile[moving_average_start_index:moving_average_end_index] .- (moving_average_start_index - 100)
@info(plot_name, T_profile[1], P_profile[1], ICNC_profile[1], e_profile[1])
sleep(3)
T_profile = AIDA_T_profile[moving_average_start_index:moving_average_end_index]
P_profile = AIDA_P_profile[moving_average_start_index:moving_average_end_index]
ICNC_profile = AIDA_ICNC[moving_average_start_index:moving_average_end_index]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[AIDA_ice_nucleation]
git-tree-sha1 = "4a298d3558691217adb253b4053611931d62c5c2"
lazy = true
git-tree-sha1 = "91a1a51fb6ebb54282e65de1a2aace5e4ef1c45a"

[[AIDA_ice_nucleation.download]]
sha256 = "b513219566a3d1125acf1515f0d80b5d212f2bb78acead15137dfff47b503f9d"
sha256 = "df37e510212e328c30f052938537ac29dd217206c266c501c2fb797faa3f4c8a"
url = "https://caltech.box.com/shared/static/imo0pyr6o0m9txu8racztmt7lz5n9xf1.gz"
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# of a function in CloudMicrophysics that is called by ClimaAtmos). For more info, please
# visit the ClimaArtifacts.jl repo on GitHub!

# To use in VS Code, first activate the AIDA_data_artifact environment.
# In terminal, make sure your pwd is in AIDA_data_artifact. Then,
# activate Julia at --project=papers/ice_nucleation_2024/AIDA_data_artifact.
# You are in the right place if you enter the shell (tap ; on keyboard) and
# see that you are in the AIDA_data_artifact folder (NOT CloudMicrophysics.jl)
# Then, copy and paste the following script to the Julia REPL.
# To use in terminal, activate Julia at --project=papers/ice_nucleation_2024/AIDA_data_artifact.
# Then, copy and paste the following script in your now opened Julia REPL.

# If you do not already have ClimaArtifactsHelper, go into the Julia REPL and type:
# Pkg.develop(url="https://github.com/CliMA/ClimaArtifacts.git", subdir="ClimaArtifactsHelper.jl")
Expand All @@ -25,7 +26,7 @@ create_artifact_guided(data_folder; artifact_name = data_set_name)

# After getting an updated "OutputArtifacts.toml" file in this folder,
# Add it to the list of artifacts in CloudMicrophysics.jl's Artifact.toml file.
# Add `lazy = true` under the `git-tree-sha1` line in Artifact.toml i fyou would like
# Add `lazy = true` under the `git-tree-sha1` line in Artifact.toml if you would like
# the artifact to be downloaded lazily.

# To use data, make sure your script has "using LazyArtifacts" at the top.
Expand Down
22 changes: 11 additions & 11 deletions papers/ice_nucleation_2024/calibration_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,34 +196,34 @@ function AIDA_IN05_IC(FT, data_file)

if data_file == "in05_17_aida.edf"
# starting at t = 205 s (to match moving average freezing onset)
Nₗ = FT(297.136 * 1e6)
Nᵢ = FT(1.49 * 1e6)
Nₗ = FT(297.060 * 1e6)
Nᵢ = FT(1.46 * 1e6)
Nₐ = FT(360 * 1e6) - Nₗ - Nᵢ
r₀ = FT(6.17664e-6) # FT(1e-7)
p₀ = FT(865.179 * 1e2)
T₀ = FT(236.91)
r₀ = FT(6.17905e-6) # FT(1e-7)
p₀ = FT(864.685 * 1e2)
T₀ = FT(236.883)
qₗ = FT(Nₗ * 4 / 3 * FT(π) * r₀^3 * ρₗ / FT(1.2)) # 1.2 should be ρₐ
qᵢ = FT(Nᵢ * 4 / 3 * FT(π) * r₀^3 * ρₗ / FT(1.2))
m_l = Nₗ * ρₗ * 4 * π / 3 * r₀^3
m_i = Nᵢ * ρᵢ * 4 * π / 3 * r₀^3
e = FT(27.0341)
e = FT(27.2137)
qᵥ = (e / R_v / T₀) / ((p₀ - e) / (R_d * T₀) + e / R_v / T₀ + m_l + m_i)
q = TD.PhasePartition.(qᵥ + qₗ + qᵢ, qₗ, qᵢ)
Rₐ = TD.gas_constant_air(tps, q)
eₛ = TD.saturation_vapor_pressure(tps, T₀, TD.Liquid())
Sₗ = FT(e / eₛ)
elseif data_file == "in05_18_aida.edf"
Nₗ = FT(209.46 * 1e6)
Nᵢ = FT(1.53 * 1e6)
Nₗ = FT(210.28 * 1e6)
Nᵢ = FT(1.73 * 1e6)
Nₐ = FT(275 * 1e6) - Nₗ - Nᵢ
r₀ = FT(7.03467 * 1e-6)
r₀ = FT(6.99998 * 1e-6)
p₀ = FT(873.322 * 1e2)
T₀ = FT(237.175)
qₗ = FT(Nₗ * 4 / 3 * FT(π) * r₀^3 * ρₗ / FT(1.2)) # 1.2 should be ρₐ
qᵢ = FT(Nᵢ * 4 / 3 * FT(π) * r₀^3 * ρₗ / FT(1.2))
m_l = Nₗ * ρₗ * 4 * π / 3 * r₀^3
m_i = Nᵢ * ρᵢ * 4 * π / 3 * r₀^3
e = FT(28.1324)
e = FT(28.086)
qᵥ = (e / R_v / T₀) / ((p₀ - e) / (R_d * T₀) + e / R_v / T₀ + m_l + m_i)
q = TD.PhasePartition.(qᵥ + qₗ + qᵢ, qₗ, qᵢ)
Rₐ = TD.gas_constant_air(tps, q)
Expand All @@ -232,7 +232,7 @@ function AIDA_IN05_IC(FT, data_file)
elseif data_file == "in05_19_aida.edf"
Nₐ = FT(0)
Nₗ = FT(180 * 1e6)
Nᵢ = FT(0.49 * 1e6)
Nᵢ = FT(0.882 * 1e6)
r₀ = FT(6.5e-6) # !!missing in dataset!!
p₀ = FT(724.545 * 1e2)
T₀ = FT(237.639)
Expand Down
9 changes: 4 additions & 5 deletions parcel/ParcelCommon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ S_i(tps, T, S_liq) = ξ(tps, T) * S_liq

# Interpolating for cooling/expansion rate
function AIDA_rate(model_t, data_t, data)
data_t = data_t[2:end]
data = data[2:end]
index = Int32(model_t) + 1
#index = Int32(model_t) + 1
data_at_t = Intp.linear_interpolation(data_t, data)

if index < length(data) - 1
return (data_at_t(model_t + 2) - data_at_t(model_t + 1))
#if index < length(data_t)
if model_t < data_t[end]
return (data_at_t(model_t + 1) - data_at_t(model_t))
else
return 0
end
Expand Down

0 comments on commit 954fb07

Please sign in to comment.