Skip to content

Commit a320300

Browse files
authored
Merge pull request #311 from BioAnalyticResource/dev
Updates
2 parents f039563 + 1a55d65 commit a320300

File tree

7 files changed

+787
-274
lines changed

7 files changed

+787
-274
lines changed

api/models/fastpheno.py

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,84 @@
1+
from datetime import datetime
12
from api import db
2-
import enum
3-
from sqlalchemy.dialects.mysql import DECIMAL, ENUM
4-
from sqlalchemy.orm import relationship
5-
from sqlalchemy import ForeignKey
6-
from typing import List
3+
from sqlalchemy.dialects.mysql import DECIMAL
74

85

96
class Sites(db.Model):
107
__bind_key__ = "fastpheno"
118
__tablename__ = "sites"
129

13-
sites_pk: db.Mapped[int] = db.mapped_column(db.Integer, nullable=False, primary_key=True)
10+
sites_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
1411
site_name: db.Mapped[str] = db.mapped_column(db.String(45), nullable=False)
15-
site_desc: db.Mapped[str] = db.mapped_column(db.String(99), nullable=True)
16-
children: db.Mapped[List["Trees"]] = relationship()
12+
lat: db.Mapped[float] = db.mapped_column(DECIMAL(15, 12), nullable=False)
13+
lng: db.Mapped[float] = db.mapped_column(DECIMAL(15, 12), nullable=False)
14+
site_desc: db.Mapped[str] = db.mapped_column(db.String(999), nullable=True)
15+
16+
17+
class Flights(db.Model):
18+
__bind_key__ = "fastpheno"
19+
__tablename__ = "flights"
20+
21+
flights_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
22+
pilot: db.Mapped[str] = db.mapped_column(db.String(45), nullable=True)
23+
flight_date: db.Mapped[datetime] = db.mapped_column(db.DateTime, nullable=False)
24+
sites_pk: db.Mapped[int] = db.mapped_column(db.Integer, nullable=False)
25+
height: db.Mapped[float] = db.mapped_column(DECIMAL(15, 10), nullable=True)
26+
speed: db.Mapped[float] = db.mapped_column(DECIMAL(15, 10), nullable=True)
1727

1828

1929
class Trees(db.Model):
2030
__bind_key__ = "fastpheno"
2131
__tablename__ = "trees"
2232

23-
trees_pk: db.Mapped[int] = db.mapped_column(db.Integer, nullable=False, primary_key=True)
24-
sites_pk: db.Mapped[int] = db.mapped_column(ForeignKey("sites.sites_pk"))
25-
longitude: db.Mapped[float] = db.mapped_column(db.Float, nullable=False)
26-
latitude: db.Mapped[float] = db.mapped_column(db.Float, nullable=False)
27-
genotype_id: db.Mapped[str] = db.mapped_column(db.String(5), nullable=True)
33+
trees_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
34+
sites_pk: db.Mapped[int] = db.mapped_column(db.Integer, nullable=False)
35+
longitude: db.Mapped[float] = db.mapped_column(DECIMAL(15, 12), nullable=False)
36+
latitude: db.Mapped[float] = db.mapped_column(DECIMAL(15, 12), nullable=False)
37+
tree_site_id: db.Mapped[str] = db.mapped_column(db.String(45), nullable=True)
38+
family_id: db.Mapped[str] = db.mapped_column(db.String(45), nullable=True)
2839
external_link: db.Mapped[str] = db.mapped_column(db.String(200), nullable=True)
29-
tree_given_id: db.Mapped[str] = db.mapped_column(db.String(25), nullable=True)
30-
children: db.Mapped[List["Band"]] = relationship()
31-
32-
33-
class MonthChoices(enum.Enum):
34-
jan = "1"
35-
feb = "2"
36-
mar = "3"
37-
apr = "4"
38-
may = "5"
39-
jun = "6"
40-
jul = "7"
41-
aug = "8"
42-
sep = "9"
43-
oct = "10"
44-
nov = "11"
45-
dec = "12"
46-
47-
48-
class Band(db.Model):
40+
block_num: db.Mapped[int] = db.mapped_column(db.Integer, nullable=True)
41+
seq_id: db.Mapped[str] = db.mapped_column(db.String(25), nullable=True)
42+
x_pos: db.Mapped[int] = db.mapped_column(db.Integer, nullable=True)
43+
y_pos: db.Mapped[int] = db.mapped_column(db.Integer, nullable=True)
44+
height_2022: db.Mapped[str] = db.mapped_column(db.String(10), nullable=True)
45+
46+
47+
class TreesFlightsJoinTbl(db.Model):
4948
__bind_key__ = "fastpheno"
50-
__tablename__ = "band"
49+
__tablename__ = "trees_flights_join_tbl"
50+
51+
trees_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
52+
flights_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
53+
confidence: db.Mapped[float] = db.mapped_column(DECIMAL(8, 5), nullable=True)
54+
5155

52-
trees_pk: db.Mapped[int] = db.mapped_column(ForeignKey("trees.trees_pk"), primary_key=True)
53-
month: db.Mapped[str] = db.mapped_column(ENUM(MonthChoices), nullable=False, primary_key=True)
54-
band: db.Mapped[float] = db.mapped_column(db.String(100), nullable=False, primary_key=True)
56+
class Bands(db.Model):
57+
__bind_key__ = "fastpheno"
58+
__tablename__ = "bands"
59+
__table_args__ = (db.Index("bands_flight_band_tree_idx", "flights_pk", "band", "trees_pk"),)
60+
61+
trees_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
62+
flights_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
63+
band: db.Mapped[str] = db.mapped_column(db.String(20), primary_key=True, nullable=False)
64+
value: db.Mapped[float] = db.mapped_column(DECIMAL(8, 5), nullable=False)
65+
66+
67+
class Pigments(db.Model):
68+
__bind_key__ = "fastpheno"
69+
__tablename__ = "pigments"
70+
71+
trees_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
72+
flights_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
73+
pigment: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
5574
value: db.Mapped[float] = db.mapped_column(DECIMAL(20, 15), nullable=False)
5675

5776

58-
class Height(db.Model):
77+
class Unispec(db.Model):
5978
__bind_key__ = "fastpheno"
60-
__tablename__ = "height"
79+
__tablename__ = "unispec"
6180

62-
trees_pk: db.Mapped[int] = db.mapped_column(ForeignKey("trees.trees_pk"), primary_key=True)
63-
month: db.Mapped[str] = db.mapped_column(ENUM(MonthChoices), nullable=False, primary_key=True)
64-
tree_height_proxy: db.Mapped[float] = db.mapped_column(DECIMAL(20, 15), nullable=False)
65-
ground_height_proxy: db.Mapped[float] = db.mapped_column(DECIMAL(20, 15), nullable=False)
81+
trees_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
82+
flights_pk: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
83+
pigment: db.Mapped[int] = db.mapped_column(db.Integer, primary_key=True, nullable=False)
84+
value: db.Mapped[float] = db.mapped_column(DECIMAL(20, 15), nullable=False)

0 commit comments

Comments
 (0)