You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: techdoc/tech-doc.tex
+22-23Lines changed: 22 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -147,7 +147,7 @@ \subsubsection*{Requirements}
147
147
\\\\
148
148
Required libraries include \texttt{os, tqdm, glob, pyimpute, pickle, rasterio, matplotlib, geopandas, sklearn, numpy,} and \texttt{pandas}. These libraries can be installed in a Python terminal using \texttt{pip}.
149
149
\\\\
150
-
Ensure that preprocessed data from R exists under \texttt{/model/input/}. There should be three folders: \texttt{geojson, historical,} and \texttt{future}, each containing the appropriate data. \texttt{geojson} and \texttt{historical} are required for model training, while \texttt{future} and \texttt{/data/pickle} is required for model predicting. Example pickle files can be found at the Box link \href{https://ucdavis.box.com/s/l5iky1y6z526r6ewifvtr6c4ccp5jsjz}{here}.
150
+
Ensure that preprocessed data from R exists under \texttt{/model/input/}. There should be three folders: \texttt{geojson, historical,} and \texttt{future}, each containing the appropriate data. \texttt{geojson} and \texttt{historical} are required for model training, while \texttt{future} and \texttt{/data/models} is required for model predicting. Example pickle files under \texttt{/data/models} can be found at the Box link \href{https://ucdavis.box.com/s/l5iky1y6z526r6ewifvtr6c4ccp5jsjz}{here}.
151
151
152
152
\subsubsection{SDM Training}
153
153
The model is trained by associating presence/absence data with zonal averages for temperature and precipitation. In other words, the model learns what zonal environmental factors typically correlate to a presence or absence of a species. When given a file containing possible future climate readings, the model can then predict how the distribution of a species may react to that climate.
\noindent There exists a future climate raster for each year (2015-2100) for each SSP (ssp126, ssp245, ssp370, ssp585). These rasters are used to predict distribution for five species, making a total of 1,720 images.
203
203
\\\\
204
-
\texttt{\href{run:../model/model\_prediction.py}{model\_prediciton.py}} is comprised of a triple-nested for loop (species > ssp > year) and two functions, \texttt{make\_predictions()} and \texttt{create\_pngs()}. The former function is responsible for steps 1-3 listed above, while the latter function is responsible for step 4. TIFF images are converted to PNG through the use of \texttt{matplotlib}, and are saved in high resolution.
204
+
\texttt{\href{run:../model/model\_prediction.py}{model\_prediciton.py}} is comprised of a triple-nested for loop (species \verb|->| ssp \verb|->| year) and two functions, \texttt{make\_predictions()} and \texttt{create\_pngs()}. The former function is responsible for steps 1-3 listed above, while the latter function is responsible for step 4. TIFF images are converted to PNG through the use of \texttt{matplotlib}, and are saved in high resolution.
205
205
206
206
\section{Web Application}
207
207
208
208
\subsection{APIs}
209
209
210
210
\subsubsection{React}
211
-
Reactjs was used to created the front end, and the main component is found under \texttt{/src/App.js}. In App.js, there are calls to the back end to gather data for the various components
211
+
React.js was used to created the front end, and the main component is found under \texttt{/src/App.js}. In App.js, there are calls to the back end to gather data for the various components
212
212
located in the \texttt{/src/components} folder. These components include:
213
213
\begin{itemize}
214
214
\item\texttt{BirdInfo.js}: returns the summary of the desired bird
@@ -282,16 +282,6 @@ \subsection{Usage}
282
282
283
283
\subsubsection{Requirements}
284
284
285
-
The front end of the application was implemented with ReactJS. For ReactJS to work, first Node.js must be installed. Information on how to do so can be found \href{https://nodejs.org/en/learn/getting-started/how-to-install-nodejs}{here}. Once Node.js is installed, download ReactJS and Leaflet. Running the following lines of code in the project root directory in either the Linux command line or the Windows terminal will install the dependencies to run the front end:
The backend developed primarily with Python 3.12, but also functions on Python 3.11. It relies primarily on FastAPI for functionality, while unit testing is done using the \texttt{pytest} python module. Ensure that the correct Python version (Python 3.12 or Python 3.11) is installed, and ensure the following Python modules are installed:
296
286
297
287
\begin{verbatim}
@@ -306,7 +296,10 @@ \subsubsection{Requirements}
306
296
pytest
307
297
\end{verbatim}
308
298
309
-
All these modules are able to be installed using the command \texttt{pip install}.
299
+
\noindent These modules can be installed by running the command \texttt{pip install -r requirements.txt} in \texttt{/backend}.
300
+
\\\\
301
+
The front end of the application was implemented with React.js. For React.js to work, first Node.js must be installed. Information on how to do so can be found \href{https://nodejs.org/en/learn/getting-started/how-to-install-nodejs}{here}. Once Node.js is installed, download React.js and Leaflet. Alternatively, running \texttt{npm install} in terminal will install the dependencies required to run the front end.
\item Start the backend first by following the following steps:
316
309
\begin{enumerate}
317
310
\item In the terminal dedicated to the back end, run the \texttt{cd} command until the current working directory of the terminal is \texttt{"project root"/backend/app}. for example, if the project is located in a folder called \texttt{birdmigration}, the working directory of the back end terminal should be \texttt{birdmigration/backend/app}.
318
-
\item If the back end is being run for the f
319
-
\item In this terminal, run the command \texttt{fastapi dev base.py}.
311
+
\item In this directory, run the command \texttt{fastapi dev base.py}.
320
312
\item To access documentation of the back end, use a web browser and navigate to \url{localhost:8000/docs}
321
313
\item The back end should update automatically with saved modifications to the file. To terminate the back end, terminate the program with a SIGINT using \texttt{control + C}, if using either a Linux or Windows command terminal.
322
314
\end{enumerate}
323
315
\item Once the back end is initialized, the front end of the application may be started.
324
316
\begin{enumerate}
325
-
\item In the terminal dedicated to running the front end, ensure the current working directory of the terminal is the root folder for the project. This can be checked by using the command \texttt{ls}, and seeing if the folder \texttt{"project root"/src}\texttt is listed.
326
-
\itemIf this is the first time the front end is being started, run the command \texttt{npm install} to ensure that all the necessary Reactjs components and shortcut commands are installed and functional in this directory.
327
-
\item Once the shortcut commands for Reactjs are installed (refer to the prior step), run the command \texttt{npm start}.
328
-
\item After a couple seconds of loading the front end application, the front end should open automatically in a new web browser window. If this window is either closed or does not open, use a web browser to navigate to \texttt{http://localhost:3000} to observe the front end User Interface.
317
+
\item In the terminal dedicated to running the front end, ensure the current working directory of the terminal is the root folder for the project. This can be checked by using the command \texttt{ls}, and seeing if the folder \texttt{"project root"/src} is listed.
318
+
\itemRun the command \texttt{npm install} to ensure that all the necessary React.js components and shortcut commands are installed and functional in this directory.
319
+
\item Once the shortcut commands for React.js are installed (refer to the prior step), run the command \texttt{npm start}.
320
+
\item After a frew minutes, the front end should open automatically in a new web browser window. If this window is either closed or does not open, use a web browser to navigate to \texttt{http://localhost:3000} to observe the front end User Interface.
329
321
\end{enumerate}
330
322
\item Do not close either terminal unless their respective application is fully terminated. If a new terminal is started and another instance of either the front end or the back end is already running, a restart of the device may be required.
331
323
\end{enumerate}
@@ -343,17 +335,24 @@ \subsection{Design}
343
335
344
336
\subsection{FAQ}
345
337
346
-
The necessary ReactJS components are installed, but the front end application is still causing an error.
338
+
\noindent\textit{The necessary React.js components are installed, but the front end application is still causing an error.}
347
339
348
340
\begin{itemize}
349
-
\item Ensure that all necessary Reactjs libraries have been installed in the project directory using the \texttt{npm install} command.
341
+
\item Ensure that all necessary React.js libraries have been installed in the project directory using the \texttt{npm install} command.
350
342
\item If the front end still does not start, the React cache may need to be cleared. In a Windows or Linux terminal, navigate to the root folder of the project using the \texttt{cd} command, and run the command npm cache clean --force to clear the React cache, and then execute \texttt{npm install}.
351
343
\end{itemize}
352
344
353
-
The terminals that house the front end and/or back end have been closed without terminating the program, and now the corresponding end point of the application will not start.
345
+
\noindent\textit{The terminals that house the front end and/or back end have been closed without terminating the program, and now the corresponding end point of the application will not start.}
354
346
355
347
\begin{itemize}
356
348
\item Restart the device, and ensure that the back end and front end applications have fully terminated before closing the terminals. This can be forced by forcing a SIGINT on the program with \texttt{control + C} on either the Windows or Linux terminal.
357
349
\end{itemize}
358
350
351
+
\noindent\textit{Running FastAPI on \texttt{base.py} fails due to missing packages}.
352
+
353
+
\begin{itemize}
354
+
\item Ensure your terminal is in the \texttt{/backend/app} directory.
355
+
\item Ensure that all required python packages are installed. This can be done by running \texttt{pip install -r requirements.txt} in \texttt{/backend}
0 commit comments