Skip to content

Commit

Permalink
Merge pull request #16 from junhyukjeon/master
Browse files Browse the repository at this point in the history
Revert branch 'master' to 3PG model
  • Loading branch information
junhyukjeon authored Jul 16, 2024
2 parents 623e74c + 6a3a391 commit 3919d40
Show file tree
Hide file tree
Showing 44 changed files with 140,619 additions and 141,883 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI
on:
push:
branches:
- master
tags: '*'
pull_request:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6'
- '1.7'
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
env:
PYTHON: ""
- uses: julia-actions/julia-runtest@v1
16 changes: 16 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Poplar
# Poplar

[![Build Status](https://github.com/junhyukjeon/Poplar.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/junhyukjeon/Poplar.jl/actions/workflows/CI.yml?query=branch%3Amaster)
140,258 changes: 70,129 additions & 70,129 deletions data/CUH.csv

Large diffs are not rendered by default.

140,258 changes: 70,129 additions & 70,129 deletions data/CUH.wea

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Poplar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include("silviculture/silviculture.jl")
@system Model(Atmosphere, Calendar, Morphology, Phenology, Physiology, Rhizosphere, Silviculture, Controller)

weather = Poplar.loadwea(Poplar.datapath("2007.wea"), tz"Asia/Seoul")
CUH = Poplar.loadwea(Poplar.datapath("CUH.wea"), tz"UTC-8")
CUH = Poplar.loadwea(Poplar.datapath("CUH.wea"), tz"America/Los_Angeles")

export Model

Expand Down
3 changes: 0 additions & 3 deletions src/atmosphere/atmosphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ include("sun.jl")
include("vaporpressure.jl")
include("weather.jl")

"""
Parent system for Sun, VaporPressure, and Weather.
"""
@system Atmosphere(Sun, VaporPressure, Weather)
14 changes: 5 additions & 9 deletions src/atmosphere/sun.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
Calculates variables related to solar position.
Perhaps consider moving latitude, longitude, altitude to another system?
"""
@system Sun begin
lat: latitude => 47.66u"°" ~ preserve(u"°", parameter)
long: longitude => 122.29u"°" ~ preserve(u"°", parameter)
Expand All @@ -19,8 +15,8 @@ Perhaps consider moving latitude, longitude, altitude to another system?
# Solar Coordinates #
#####################

# HACK always use degrees for consistency and easy tracing
# FIXME pascal version of LightEnv uses iqbal()
#HACK always use degrees for consistency and easy tracing
#FIXME pascal version of LightEnv uses iqbal()
declination_angle(declination_angle_spencer) ~ track(u"°")

# Goudriaan 1977
Expand All @@ -35,20 +31,20 @@ Perhaps consider moving latitude, longitude, altitude to another system?
23.5u"°" * cos(g)
end ~ track(u"°")

# Iqbal (1983) Pg 10 Eqn 1.3.3, and sundesign.com.
# Iqbal (1983) Pg 10 Eqn 1.3.3, and sundesign.com
declination_angle_iqbal(d) => begin
g = 2pi * (d + 284u"d") / 365u"d"
23.45u"°" * sin(g)
end ~ track(u"°")

# Campbell and Norman, p168.
# Campbell and Norman, p168
declination_angle_campbell(d) => begin
a = deg2rad(356.6 + 0.9856u"d^-1" * d)
b = deg2rad(278.97 + 0.9856u"d^-1" * d + 1.9165sin(a))
asind(0.39785sin(b))
end ~ track(u"°")

# Spencer equation, Iqbal (1983) Pg 7 Eqn 1.3.1. Most accurate among all.
# Spencer equation, Iqbal (1983) Pg 7 Eqn 1.3.1. Most accurate among all
declination_angle_spencer(d) => begin
# gamma: day angle
g = 2pi * (d - 1u"d") / 365u"d"
Expand Down
9 changes: 3 additions & 6 deletions src/atmosphere/vaporpressure.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
Calculates vapor pressure.
"""
@system VaporPressure begin
# Campbell and Norman (1998), p 41 Saturation vapor pressure in kPa
a => 0.611 ~ preserve(u"kPa", parameter)
Expand All @@ -14,18 +11,18 @@ Calculates vapor pressure.

# slope of the sat vapor pressure curve: first order derivative of Es with respect to T
Δ(es, b, c; T(u"°C")): saturation_slope_delta => (e = es(T); t = Cropbox.deunitfy(T); e*(b*c)/(c+t)^2 / u"K") ~ call(u"kPa/K")
sat_slope(Δ; T(u"°C"), P(u"kPa")): saturation_slope => Δ(T) / P ~ call(u"K^-1")
ss(Δ; T(u"°C"), P(u"kPa")): saturation_slope => Δ(T) / P ~ call(u"K^-1")

#==============
VPD Calculation
==============#

"VPD"
VPD(T_air, RH, D): vapor_pressure_deficit => D(T_air, RH) ~ track(u"kPa")
VPD(T_air, RH, D) => D(T_air, RH) ~ track(u"kPa")

"Vapor pressure saturation slope delta"
VPD_Δ(T_air, Δ): vapor_pressure_saturation_slope_delta => Δ(T_air) ~ track(u"kPa/K")

"Vapor pressure saturation slope"
VPD_s(T_air, P_air, sat_slope): vapor_pressure_saturation_slope => sat_slope(T_air, P_air) ~ track(u"K^-1")
VPD_s(T_air, P_air, ss): vapor_pressure_saturation_slope => ss(T_air, P_air) ~ track(u"K^-1")
end
7 changes: 3 additions & 4 deletions src/atmosphere/weather.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
Weather
"""
@system Weather begin
#=========
Parameters
=========#

# DataFrame containing all hourly weather data should be
# assigned to this variable during configuration.
"Data"
data ~ provide(init=time, parameter)

Expand All @@ -20,7 +19,7 @@ Weather
================#

"Solar Radiation"
solar_radiation ~ drive(from=data, by=:SolRad, u"W/m^2")
solrad: solar_radiation ~ drive(from=data, by=:SolRad, u"W/m^2")

"Relative Humidity"
RH: relative_humidity ~ drive(from=data, by=:RH, u"percent")
Expand Down
9 changes: 1 addition & 8 deletions src/calendar/calendar.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
"""
Calendar keeps track of date and time-related variables.
Calendar keeps track of date and time throughout simulation.
"""
@system Calendar begin
"Initial date"
init ~ preserve::datetime(extern, parameter)

"Last date"
last => nothing ~ preserve::datetime(extern, parameter, optional)

"Time"
time(t0=init, t=context.clock.time) => t0 + convert(Cropbox.Dates.Second, t) ~ track::datetime

"Date"
date(time) => Cropbox.Dates.Date(time) ~ track::date

"Timestep"
step(context.clock.step) ~ preserve(u"hr")

stop(time, last) => begin
Expand All @@ -29,9 +24,7 @@ Calendar keeps track of date and time-related variables.
end
end ~ preserve::int(round, optional)

"Day of year"
d(time) => Dates.dayofyear(time) ~ track::int(u"d")

"Hour of day"
h(time) => Dates.hour(time) ~ track::int(u"hr")
end
6 changes: 3 additions & 3 deletions src/config/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ include("../rhizosphere/soil.jl")
# Weather data MUST include the date range specified.
config_Calendar = @config(
:Calendar => (
init = ZonedDateTime(2014, 4, 5, tz"UTC-8"),
last = ZonedDateTime(2021, 12, 31, tz"UTC-8"),
init = ZonedDateTime(2014, 4, 5, tz"America/Los_Angeles"),
last = ZonedDateTime(2021, 12, 31, tz"America/Los_Angeles"),
)
)

# Weather data must be included.
config_Atmosphere = @config(
:Atmosphere => (
data = Poplar.loadwea(Poplar.datapath("CUH.wea"), tz"UTC-8"),
data = Poplar.loadwea(Poplar.datapath("CUH.wea"), tz"America/Los_Angeles"),
)
)

Expand Down
2 changes: 0 additions & 2 deletions src/morphology/catkin.jl

This file was deleted.

Loading

0 comments on commit 3919d40

Please sign in to comment.