diff --git a/Classim/CustomTool/createManRepWindow.py b/Classim/CustomTool/createManRepWindow.py
index bf85ef2..810ff05 100644
--- a/Classim/CustomTool/createManRepWindow.py
+++ b/Classim/CustomTool/createManRepWindow.py
@@ -6,16 +6,12 @@
from DatabaseSys.Databasesupport import *
from pprint import pprint
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-dbDir = os.path.join(gparent_dir,'classim')
-
class createManRepWindow(QWidget):
"""
This window is a QWidget.
"""
def __init__(self):
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
super().__init__()
self.setGeometry(0,0,520,400)
diff --git a/Classim/CustomTool/custom1.py b/Classim/CustomTool/custom1.py
index a3c91db..e59f03d 100644
--- a/Classim/CustomTool/custom1.py
+++ b/Classim/CustomTool/custom1.py
@@ -6,8 +6,6 @@
from DatabaseSys.Databasesupport import *
from PyQt5.QtCore import Qt, QModelIndex, QVariant, QAbstractItemModel
-# add all the custom listbox, signal and slot cases here
-username=os.environ['username']
KEY,NODE = range(2)
@contextmanager
diff --git a/Classim/CustomTool/genDictOutput.py b/Classim/CustomTool/genDictOutput.py
index 81d6aea..954247e 100644
--- a/Classim/CustomTool/genDictOutput.py
+++ b/Classim/CustomTool/genDictOutput.py
@@ -4,10 +4,6 @@
from time import mktime
from shutil import copyfile
-global app_dir
-global index
-
-
'''
Generates dictionaries that will be used on outputTab.py and RotOutputTab.py. The dictionaries correpond to
tables on cropOutput database.
@@ -30,7 +26,7 @@ def genDictOutput(cropArr,tabName,rotFlag):
'LeafN':'Leaf nitrogen content (crop)','PCRL':'Carbon allocated to roots (crop)','totalDM':'Total dry matter (crop)',
'shootDM':'Shoot dry matter (crop)','earDM':'Ear dry matter (crop)','TotLeafDM':'Leaf dry matter (crop)',
'DrpLfDM':'Dropped leaf dry matter (crop)','stemDM':'Stem dry matter (crop)','rootDM':'Root dry matter (crop)',
- 'SoilRt':'Soil root dry matter (crop)','MxRtDep':'Maximum root depth (crop)','AvailW':'Available water in root zone (crop)',
+ 'SoilRt':'Carbon in soil roots (crop)','MxRtDep':'Maximum root depth (crop)','AvailW':'Available water in root zone (crop)',
'solubleC':'Soluble sugars as carbon (crop)'}
varDescUnitMaiDict = {'Leaves':'Number of leaves (appeared) (crop)','MaturLvs':'Number of mature leaves (crop)',
'Dropped':'Number of dropped leaves (crop)','LA_pl':'Green leaf area per plant (crop) (cm2)',
@@ -41,14 +37,14 @@ def genDictOutput(cropArr,tabName,rotFlag):
'Tcan':'Canopy temperature (crop) (oC)','ETdmd':'Potential Transpiration (crop) (g/plant)',
'ETsply':'Actual Transpiration (crop) (g/plant)','Pn':'Net Photosynthesis (crop) (g carbon/plant/day)',
'Pg':'Gross photosynthesis (crop) (g carbon/plant/day)','Respir':'Respiration (crop) (g carbon/plant/day)',
- 'av_gs':'Average stomatal conductance (crop)','VPD':'Vapor pressure density (crop) (kPa)',
+ 'av_gs':'Average stomatal conductance (crop) (micro-mol/m2/s)','VPD':'Vapor pressure density (crop) (kPa)',
'Nitr':'Total nitrogen in the plant (crop) (mg/plant)','N_Dem':'Nitrogen demand (crop) (g/plant)',
'NUpt':'Nitrogen uptake (crop) (g/plant)','LeafN':'Leaf nitrogen content (crop) (%)',
'PCRL':'Carbon allocated to roots (crop) (g/plant)','totalDM':'Total dry matter (crop) (g/plant)',
'shootDM':'Shoot dry matter (crop) (g/plant)','earDM':'Ear dry matter (crop) (g/plant)',
'TotLeafDM':'Leaf dry matter (crop) (g/plant)','DrpLfDM':'Dropped leaf dry matter (crop) (g/plant)',
'stemDM':'Stem dry matter (crop) (g/plant)','rootDM':'Root dry matter (crop) (g/plant)',
- 'SoilRt':'Soil root dry matter (crop) (g/plant)','MxRtDep':'Maximum root depth (crop) (cm)',
+ 'SoilRt':'Carbon in soil roots (crop) (g/plant)','MxRtDep':'Maximum root depth (crop) (cm)',
'AvailW':'Available water in root zone (crop) (g)','solubleC':'Soluble sugars as carbon (crop) (g/plant)'}
varFuncMaiDict = {'Leaves':'max','MaturLvs':'max','Dropped':'max','LA_pl':'max','LA_dead':'max','LAI':'max',
'RH':'mean','LeafWP':'mean','PFD':'sum','SolRad':'mean','SoilT':'mean','Tair':'mean',
@@ -60,7 +56,7 @@ def genDictOutput(cropArr,tabName,rotFlag):
# Potato
varDescPotDict = {'LAI':'Leaf area index (crop)','PFD':'Photosynthetic flux density (crop)','SolRad':'Solar radiation (crop)',
'Tair':'Air temperture at 2m (crop)','Tcan':'Canopy temperature (crop)','Pgross':'Gross photosynthesis (crop)',
- 'Rg+Rm':'Respiration (crop)','Tr-Pot':'Potential Transpiration (crop)','Tr-Act':'Actual Transpiration (crop)',
+ 'Rg+Rm':'Respiration (crop)','Tr-Pot':'Potential transpiration (crop)','Tr-Act':'Actual transpiration (crop)',
'Stage':'Stage (crop)','totalDM':'Total dry matter (crop)','leafDM':'Leaf dry matter (crop)',
'stemDM':'Stem dry matter (crop)','rootDM':'Root dry matter (crop)','tuberDM':'Tuber dry matter (crop)',
'deadDM':'Dead dry matter (crop)','LWPave':'Leaf water potential (crop)','gs_ave':'Average stomatal conductance (crop)',
@@ -69,15 +65,15 @@ def genDictOutput(cropArr,tabName,rotFlag):
varDescUnitPotDict = {'LAI':'Leaf area index (crop)','PFD':'Photosynthetic flux density (crop) (mol photons/day/m2)',
'SolRad':'Solar radiation (crop) (W/m2)','Tair':'Air temperture at 2m (crop) (oC)',
'Tcan':'Canopy temperature (crop) (oC)','Pgross':'Gross photosynthesis (crop) (g carbon/plant/day)',
- 'Rg+Rm':'Respiration (crop) (g carbon/plant/day)','Tr-Pot':'Potential Transpiration (crop) (mg/plant)',
- 'Tr-Act':'Actual Transpiration (crop) (mg/plant)','Stage':'Stage (crop)',
+ 'Rg+Rm':'Respiration (crop) (g carbon/plant/day)','Tr-Pot':'Potential transpiration (crop) (mg/plant)',
+ 'Tr-Act':'Actual transpiration (crop) (mg/plant)','Stage':'Stage (crop)',
'totalDM':'Total dry matter (crop) (g/plant)','leafDM':'Leaf dry matter (crop) (g/plant)',
'stemDM':'Stem dry matter (crop) (g/plant)','rootDM':'Root dry matter (crop) (g/plant)',
'tuberDM':'Tuber dry matter (crop) (g/plant)','deadDM':'Dead dry matter (crop) (g/plant)',
- 'LWPave':'Leaf water potential (crop) (bars)','gs_ave':'Average stomatal conductance (crop)',
- 'N_uptake':'Nitrogen Uptake (crop) (mg/plant)','tot_N':'Total Nitrogen in the Plant (crop) (mg/plant)',
- 'leaf_N':'Leaf nitrogen content (crop) (mg/plant)','stem_N':'Stem nitrogen (crop) (mg/plant)',
- 'root_N':'Root nitrogen (crop) (mg/plant)','tuber_N':'Tuber nitrogen (crop) (mg/plant)'}
+ 'LWPave':'Leaf water potential (crop) (bars)','gs_ave':'Average stomatal conductance (crop) (micro-mol/m2/s)',
+ 'N_uptake':'Nitrogen Uptake (crop) (g/plant)','tot_N':'Total Nitrogen in the Plant (crop) (g/plant)',
+ 'leaf_N':'Leaf nitrogen content (crop) (g/plant)','stem_N':'Stem nitrogen (crop) (g/plant)',
+ 'root_N':'Root nitrogen (crop) (g/plant)','tuber_N':'Tuber nitrogen (crop) (g/plant)'}
varFuncPotDict = {'LAI':'max','PFD':'sum','SolRad':'mean','Tair':'mean','Tcan':'mean','Pgross':'sum',
'Rg+Rm':'sum','Tr-Pot':'sum','Tr-Act':'sum','Stage':'max','totalDM':'max','leafDM':'max',
'stemDM':'max','rootDM':'max','tuberDM':'max','deadDM':'max','LWPave':'mean','gs_ave':'mean',
@@ -86,15 +82,15 @@ def genDictOutput(cropArr,tabName,rotFlag):
# Soybean
varDescSoyDict = {'PFD':'Photosynthetic flux density (crop)','SolRad':'Solar radiation (crop)','Tair':'Air temperture at 2m (crop)',
'Tcan':'Canopy temperature (crop)','Pgross':'Gross photosynthesis (crop)','Pnet':'Net photosynthesis (crop)',
- 'gs':'Maximum stomatal conductance (crop)','PSIL':'Leaf Water Potential (crop)','LAI':'Leaf area index (crop)',
+ 'gs':'Maximum stomatal conductance (crop)','PSIL':'Leaf water potential (crop)','LAI':'Leaf area index (crop)',
'LAREAT':'Leaf area (crop)','totalDM':'Total dry matter (crop)','rootDM':'Root dry matter (crop)',
'stemDM':'Stem dry matter (crop)','leafDM':'Leaf dry matter (crop)','seedDM':'Seed dry matter (crop)',
- 'podDM':'Pod dry matter (crop)','DeadDM':'Dead dry matter (crop)','Tr_pot':'Potential Transpiration (crop)',
- 'Tr_act':'Actual Transpiration (crop)'}
+ 'podDM':'Pod dry matter (crop)','DeadDM':'Dead dry matter (crop)','Tr_pot':'Potential transpiration (crop)',
+ 'Tr_act':'Actual transpiration (crop)'}
varDescUnitSoyDict = {'PFD':'Photosynthetic flux density (crop) (mol photons/day/m2)','SolRad':'Solar radiation (crop) (W/m2)',
'Tair':'Air temperture at 2m (crop) (oC)','Tcan':'Canopy temperature (crop) (oC)',
'Pgross':'Gross photosynthesis (crop) (g carbon/plant/day)','Pnet':'Net photosynthesis (crop) (g carbon/plant/day)',
- 'gs':'Maximum stomatal conductance (crop)','PSIL':'Leaf Water Potential (crop) (bars)',
+ 'gs':'Maximum stomatal conductance (crop)','PSIL':'Leaf water potential (crop) (bars)',
'LAI':'Leaf area index (crop)','LAREAT':'Leaf area (crop) (cm2)',
'totalDM':'Total dry matter (crop) (g/plant)','rootDM':'Root dry matter (crop) (g/plant)',
'stemDM':'Stem dry matter (crop) (g/plant)','leafDM':'Leaf dry matter (crop) (g/plant)',
@@ -110,36 +106,36 @@ def genDictOutput(cropArr,tabName,rotFlag):
varDescCotDict = {'PlantH':'Plant height (crop)','LAI':'Leaf area index (crop)','LInt':'Canopy light interception (crop)','Nodes':'Number of main stem nodes (crop)',
'Sites':'Number of fruiting sites (crop)','N_Squares':'Number of squares (crop)','N_GB':'Number of green bolls (crop)',
'NLvsLoss':'Total number of leaves lost (crop)','NSqLoss':'Total number of squares lost (crop)','NBollsLoss':'Total number of bolls lost (crop)',
- 'NFruitShed':'Total number of abscissed fruits (crop)','PetShd_DM':'Petal shed dry matter (crop)','GB_lossDM':'Green bolls lost dry matter (crop)',
- 'Lf_lossDM':'Leaves abscissed dry matter (crop)','Rt_lossDM':'Root lost dry matter (crop)','Dd_WtDM':'Dead tissue lost dry matter (crop)',
+ 'NFruitShed':'Total number of abscised fruits (crop)','PetShd_DM':'Petal shed dry matter (crop)','GB_lossDM':'Green bolls lost dry matter (crop)',
+ 'Lf_lossDM':'Leaves abscised dry matter (crop)','Rt_lossDM':'Root lost dry matter (crop)','Dd_WtDM':'Dead tissue lost dry matter (crop)',
'SquareDM':'Squares dry matter (crop)','GB_DM':'Green boll dry matter (crop)','OB_DM':'Open boll dry matter (crop)','LeafDM':'Leaf dry matter (crop)',
'StemDM':'Stem dry matter (crop)','RootDM':'Root dry matter (crop)','ResC':'Reserved dry matter (crop)','PlantDM':'Total plant dry matter (crop)',
'R_S':'Root shoot ratio (crop)','Yield':'Total yield (crop)','Temp':'Average temperature (crop)','L_Temp':'Average leaf temperature (crop)',
'Rain':'Rain+irrigation (crop)','SRad':'Solar radiation (crop)','PFD':'Photosynthetic flux density (crop)','RH':'Relative humidity (crop)',
- 'LeafN':'Leaf nitrogen (crop)','StemN':'Stem nitrogen (crop)','SeedN':'seed nitrogen (crop)','BurrN':'Burr nitrogen (crop)','RootN':'Root nitrogen (crop)',
+ 'LeafN':'Leaf nitrogen content (crop)','StemN':'Stem nitrogen (crop)','SeedN':'Seed nitrogen (crop)','BurrN':'Burr nitrogen (crop)','RootN':'Root nitrogen (crop)',
'Nloss':'Nitrogen lost abscission (crop)','PlantN':'Total Nitrogen in the Plant (crop)','N_uptake':'Total nitrogen uptake (crop)',
'S_Psi':'Average soil water potential in the root zone (crop)','L_Psi':'Leaf water potential (crop)','LArea':'Leaf area (crop)',
- 'VPD':'Vapour pressure deficit (crop)','StCond':'Stomatal conductance (crop)','Pnet':'Net photosynthesis (crop)','PGross':'Gross photosynthesis (crop)',
- 'L_Res':'Light respiration (crop)', 'Main_Res':'Maintanance respiration (crop)','Resp':'Total respiration (crop)','SPnet':'Cumulative net photosynthesis (crop)',
+ 'VPD':'Vapor pressure density (crop)','StCond':'Average stomatal conductance (crop)','Pnet':'Net photosynthesis (crop)','PGross':'Gross photosynthesis (crop)',
+ 'L_Res':'Light respiration (crop)', 'Main_Res':'Maintenance respiration (crop)','Resp':'Total respiration (crop)','SPnet':'Cumulative net photosynthesis (crop)',
'C_Bal':'Plant C balance (crop)','Nstress_Pn':'Nitrogen stress on the photosynthesis (crop)' }
varDescUnitCotDict = {'PlantH':'Plant height (crop) (cm)','LAI':'Leaf area index (crop)','LInt':'Canopy light interception (crop)','Nodes':'Number of main stem nodes (crop)',
'Sites':'Number of fruiting sites (crop)','N_Squares':'Number of squares (crop)','N_GB':'Number of green bolls (crop)',
'NLvsLoss':'Total number of leaves lost (crop)','NSqLoss':'Total number of squares lost (crop)','NBollsLoss':'Total number of bolls lost (crop)',
- 'NFruitShed':'Total number of abscissed fruits (crop)','PetShd_DM':'Petal shed dry matter (crop) (g carbon/plant)',
- 'GB_lossDM':'Green bolls lost dry matter (crop) (g carbon/plant)','Lf_lossDM':'Leaves abscissed dry matter (crop) (g carbon/plant)',
+ 'NFruitShed':'Total number of abscised fruits (crop)','PetShd_DM':'Petal shed dry matter (crop) (g carbon/plant)',
+ 'GB_lossDM':'Green bolls lost dry matter (crop) (g carbon/plant)','Lf_lossDM':'Leaves absciseddry matter (crop) (g carbon/plant)',
'Rt_lossDM':'Root lost dry matter (crop) (g carbon/plant)','Dd_WtDM':'Dead tissue lost dry matter (crop) (g/plant)',
'SquareDM':'Squares dry matter (crop) (g/plant)','GB_DM':'Green boll dry matter (crop) (g/plant)','OB_DM':'Open boll dry matter (crop) (g/plant)',
'LeafDM':'Leaf dry matter (crop) (g/plant)','StemDM':'Stem dry matter (crop) (g/plant)','RootDM':'Root dry matter (crop) (g/plant)',
'ResC':'Reserved dry matter (crop) (g carbon/plant)','PlantDM':'Total plant dry matter (crop) (g carbon/plant)','R_S':'Root shoot ratio (crop)',
'Yield':'Total yield (crop) (kg/ha)','Temp':'Average temperature (crop) (oC)','L_Temp':'Average leaf temperature (crop) (oC)',
'Rain':'Rain+irrigation (crop) (mm/day)','SRad':'Solar radiation (crop) (W/m2)','PFD':'Photosynthetic flux density (crop) (mol photons/m2/day)',
- 'RH':'Relative humidity (crop) (%)','LeafN':'Leaf nitrogen (crop) (g Nitrogen/plant)','StemN':'Stem nitrogen (crop) (g Nitrogen/plant)',
- 'SeedN':'seed nitrogen (crop) (g Nitrogen/plant)','BurrN':'Burr nitrogen (crop) (g Nitrogen/plant)','RootN':'Root nitrogen (crop) (g Nitrogen/plant)',
+ 'RH':'Relative humidity (crop) (%)','LeafN':'Leaf nitrogen content (crop) (g Nitrogen/plant)','StemN':'Stem nitrogen (crop) (g Nitrogen/plant)',
+ 'SeedN':'Seed nitrogen (crop) (g Nitrogen/plant)','BurrN':'Burr nitrogen (crop) (g Nitrogen/plant)','RootN':'Root nitrogen (crop) (g Nitrogen/plant)',
'Nloss':'Nitrogen lost abscission (crop) (g Nitrogen/plant)','PlantN':'Total Nitrogen in the Plant (crop) (g/plant)',
'N_uptake':'Total nitrogen uptake (crop) (g Nitrogen/plant)','S_Psi':'Average soil water potential in the root zone (crop) (bar)',
- 'L_Psi':'Leaf water potential (crop) (bar)','LArea':'Leaf area (crop) (cm2)','VPD':'Vapour pressure deficit (crop) (k Pa)',
- 'StCond':'Stomatal conductance (crop) (micro-mol/m2/sec)','Pnet':'Net photosynthesis (crop) (g carbon/plant)',
- 'PGross':'Gross photosynthesis (crop) (g carbon/plant)','L_Res':'Light respiration (crop) (g carbon/plant)','Main_Res':'Maintanance respiration (crop) (g carbon/plant)', 'Resp':'Total respiration (crop) (g carbon/plant)',
+ 'L_Psi':'Leaf water potential (crop) (bar)','LArea':'Leaf area (crop) (cm2)','VPD':'Vapor pressure density (crop) (k Pa)',
+ 'StCond':'Average stomatal conductance (crop) (micro-mol/m2/sec)','Pnet':'Net photosynthesis (crop) (g carbon/plant)',
+ 'PGross':'Gross photosynthesis (crop) (g carbon/plant)','L_Res':'Light respiration (crop) (g carbon/plant)','Main_Res':'Maintenance respiration (crop) (g carbon/plant)', 'Resp':'Total respiration (crop) (g carbon/plant)',
'SPnet':'Cumulative net photosynthesis (crop) (g carbon/plant)', 'C_Bal':'Plant C balance (crop) (g carbon/plant)',
'Nstress_Pn':'Nitrogen stress on the photosynthesis (crop)'}
varFuncCotDict = {'PlantH':'max','LAI':'max','LInt':'max','Nodes':'max','Sites':'max','N_Squares':'max','N_GB':'max','NLvsLoss':'max','NSqLoss':'max','NBollsLoss':'max',
diff --git a/Classim/CustomTool/generateModelInputFiles.py b/Classim/CustomTool/generateModelInputFiles.py
index b09bfd9..17f6d20 100644
--- a/Classim/CustomTool/generateModelInputFiles.py
+++ b/Classim/CustomTool/generateModelInputFiles.py
@@ -6,6 +6,7 @@
import pandas as pd
from CustomTool.custom1 import *
from CustomTool.UI import *
+from CustomTool.getClassimDir import *
from DatabaseSys.Databasesupport import *
from Models.cropdata import *
from TabbedDialog.tableWithSignalSlot import *
@@ -14,30 +15,17 @@
from PyQt5.QtCore import QFile, QTextStream, QIODevice
-global runpath1
-global app_dir
-global repository_dir
-
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-app_dir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(app_dir):
- os.makedirs(app_dir)
-
-global db
-db = app_dir+'\\crop.db'
-
-run_dir = os.path.join(app_dir,'run')
-if not os.path.exists(run_dir):
- os.makedirs(run_dir)
-
-runpath1= run_dir
-repository_dir = os.path.join(runpath1,'store')
+global classimDir
+global runDir
+global storeDir
+classimDir = getClassimDir()
+runDir = os.path.join(classimDir,'run')
+storeDir = os.path.join(runDir,'store')
## This should always be there
-if not os.path.exists(repository_dir):
- print('RotationTab Error: Missing repository_dir')
+if not os.path.exists(storeDir):
+ print('RotationTab Error: Missing store folder.')
def copyFile(src,dest):
@@ -329,11 +317,11 @@ def WriteCropVariety(crop,cultivar,field_name,field_path):
fh.close()
-def WriteWeather(experiment,treatmentname,stationtype,weather,field_name,field_path,tempVar,rainVar,CO2Var):
+def WriteWeather(experiment,treatmentname,stationtype,weather,field_path,tempVar,rainVar,CO2Var):
# First create .wea file that stores the daily/hourly weather information for the simulation period
filename = field_path+'\\'+stationtype + '.wea'
# getting weather data from sqlite
- conn, c = openDB(db)
+ conn, c = openDB('crop.db')
# get date range for treatment
op_date_query = "select distinct odate from operations o, treatment t, experiment e where t.tid = o.o_t_exid and e.exid=t.t_exid and e.name=? and t.name = ?"
@@ -658,7 +646,6 @@ def WriteMulchGeo(field_path,nutrient):
mulchDecompList = getMulchDecomp(nutrient)
CODEC="UTF-8"
- #field_path = os.path.join(runpath1,field_name)
filename = field_path+'\\MulchGeo.mul'
fh = QFile(filename)
diff --git a/Classim/CustomTool/textureclass64.dll b/Classim/CustomTool/textureclass64.dll
deleted file mode 100644
index b43ad13..0000000
Binary files a/Classim/CustomTool/textureclass64.dll and /dev/null differ
diff --git a/Classim/DatabaseSys/Databasesupport.py b/Classim/DatabaseSys/Databasesupport.py
index 32f4afe..e7b5e1a 100644
--- a/Classim/DatabaseSys/Databasesupport.py
+++ b/Classim/DatabaseSys/Databasesupport.py
@@ -7,14 +7,7 @@
from datetime import datetime as dt
from datetime import datetime, timedelta
from CustomTool.UI import *
-
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-# dbDir is the same as run_dir
-dbDir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(dbDir):
- os.makedirs(dbDir)
-
+from CustomTool.getClassimDir import *
def openDB(database):
'''
@@ -24,7 +17,8 @@ def openDB(database):
Output:
database connector and cursor
'''
- conn = sqlite3.connect(database)
+ dbDir = getClassimDir()
+ conn = sqlite3.connect(dbDir+'\\'+database)
c = conn.cursor()
if not c:
print("database not open")
@@ -40,7 +34,7 @@ def insert_update_sitedetails(record_tuple,buttontext):
record_tuple=(sitename, latitude, longitude, altitude)
buttontext is Save or Update
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
record_tuple4= record_tuple[1:] + (record_tuple[0],)
if buttontext == 'SaveAs':
@@ -58,7 +52,7 @@ def delete_sitedetails(site):
Input:
record_tuple = (sitename)
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
# First update site_id=23 (Generic Site) if there is any soil associated with this site
c.execute("update soil set site_id=23 where site_id=(select si.id from sitedetails si where sitename=?)",(site,))
@@ -84,7 +78,7 @@ def extract_sitedetails(site_string):
'''
result1 =0
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("select id,rlat,rlon,altitude from sitedetails where sitename = '%s';"%(site_string))
c1_row = c1.fetchall()
@@ -103,7 +97,7 @@ def read_cropDB():
Tuple with crop name
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("SELECT id, cropname FROM crops order by lower(cropname)")
@@ -128,7 +122,7 @@ def read_cultivar_DB(cropname):
tuple with hybridname list for specific crop
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#print("cropname=",cropname)
if len(cropname) > 0:
@@ -156,7 +150,7 @@ def read_tillageTypeDB():
Tuple with tillage types name
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("SELECT id, tillage FROM tillageType order by lower(tillage)")
@@ -178,7 +172,7 @@ def read_PGRChemicalDB():
Tuple with PGR chemical types name
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("SELECT id, PGRChemical FROM PGRChemical order by lower(PGRChemical)")
@@ -200,7 +194,7 @@ def read_PGRAppTypeDB():
Tuple with PGR application types name
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("SELECT id, applicationType FROM PGRApplType order by lower(applicationType)")
@@ -222,7 +216,7 @@ def read_PGRAppUnitDB():
Tuple with PGR application units
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("SELECT id, PGRUnit FROM PGRUnit order by lower(PGRUnit)")
@@ -244,7 +238,7 @@ def read_SurfResTypeDB():
Tuple with surface residue type
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("select residueType from surfResType order by lower(residueType)")
@@ -265,7 +259,7 @@ def read_SurfResApplTypeDB():
Tuple with surface residue application type
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("select applicationType from surfResApplType order by lower(applicationType)")
@@ -290,7 +284,7 @@ def read_cultivar_DB_detailed(hybridname,cropname):
tuple with complete information about a particular hybridname
'''
rlist =() # tuple
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(cropname) > 0:
if cropname == "maize":
@@ -326,7 +320,7 @@ def read_experimentDB():
tuple with experiment names
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("SELECT exid, name FROM experiment order by experiment")
@@ -349,7 +343,7 @@ def getExpTreatByCrop(cropname):
tuple with experiment names
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#need auto increment ID, nonnull
c1 = c.execute("select e.name || '/' || t.name as expTreat from experiment e, treatment t where t_exid=exid and e.crop = ? order by lower(e.name), lower(t.name)",[cropname])
@@ -372,7 +366,7 @@ def getExpTreatByCropWeatherDate(cropname,stationtype,weatherID):
tuple with experiment names
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
# Find the date range for the weatherID data
record_tuple = (stationtype,weatherID)
@@ -404,7 +398,7 @@ def read_experimentDB_id(cropname, experimentname):
experiment id
'''
rlist =None
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
record_tuple =(cropname,experimentname)
if len(cropname) > 0 and len(experimentname) > 0:
@@ -426,7 +420,7 @@ def read_operationsDB_id(o_t_exid):
tuple listing all operations with full detail.
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if isinstance(o_t_exid,int):
c2 = c.execute("SELECT opID, name, odate FROM operations where o_t_exid = ?", (o_t_exid,))
@@ -448,7 +442,7 @@ def getPlantDensity(o_t_exid):
plant density
'''
rlist = ""
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if isinstance(o_t_exid,int):
c2 = c.execute("SELECT pop FROM initCondOp where opID = (select opID from operations where \
@@ -471,7 +465,7 @@ def read_treatmentDB_id(exid,treatmentname):
tid = treatment id
'''
rlist =None
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
treatmentname2 = treatmentname+'%'
record_tuple =(exid,treatmentname2)
@@ -494,7 +488,7 @@ def check_and_update_experimentDB(item,cropname):
Output:
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(item) > 0:
c1 = c.execute("SELECT exid, name FROM experiment where name = '%s' and crop = '%s';" %(''.join(item),''.join(cropname)))
@@ -515,7 +509,7 @@ def check_and_delete_soilDB(soilname):
soilname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
id = 0
c.execute("Select id, o_gridratio_id FROM soil where soilname =?",[soilname])
@@ -541,7 +535,7 @@ def delete_soilDB(soilname):
soilname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
id = 0
c.execute("Select id, o_gridratio_id FROM soil where soilname =?",[soilname])
@@ -567,7 +561,7 @@ def check_and_delete_experimentDB(experimentname,cropname):
Output:
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
record_tuple = (experimentname,cropname)
if len(experimentname) > 0:
@@ -597,7 +591,7 @@ def check_and_delete_treatmentDB(treatmentname, experimentname ,cropname):
cropname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT exid, name FROM experiment where name = '%s' and crop = '%s';" %(''.join(experimentname),''.join(cropname)))
c1_row = c1.fetchone()
@@ -628,7 +622,7 @@ def isSiteOnPastruns(site):
Output:
true/false
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1row = c.execute("select count(id) from pastruns where site = ?",(site,))
c1_row = c1row.fetchone()
@@ -661,7 +655,7 @@ def update_pastrunsDB(rotationID,site,managementname,weather,stationtype,soilnam
pastrun id
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
odate = datetime.now()
@@ -688,7 +682,7 @@ def delete_pastrunsDB(id,cropname):
cropname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
query = "delete from pastruns where id=" + id
c.execute(query)
@@ -712,7 +706,7 @@ def delete_pastrunsDB_rotationID(rotationID,run_dir,cropname):
id
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
# Find which runs belong to this rotationID
query = "select id from pastruns where rotationID = " + str(rotationID)
@@ -737,7 +731,7 @@ def extract_pastrunsidDB(id):
Tuple with complete pastruns information.
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if id == 0:
query = 'select id, rotationID, site, soil, stationtype, weather, treatment, startyear, endyear, waterstress, \
@@ -761,7 +755,7 @@ def getNextRotationID():
Output:
rotationID
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1=c.execute("select max(rotationID) from pastruns")
c1_row = c1.fetchone()
@@ -783,7 +777,7 @@ def getTreatmentID(treatmentname, experimentname, cropname):
Output:
treatmentID
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#print("cropname=",cropname)
record_tuple =(treatmentname,experimentname,cropname)
@@ -805,7 +799,7 @@ def check_and_update_treatmentDB(treatmentname, experimentname, cropname):
cropname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
record_tuple =(treatmentname,experimentname,cropname)
if c:
#print("cropname=",cropname)
@@ -887,7 +881,7 @@ def copy_treatmentDB(treatmentname, experimentname, cropname, newtreatmentname):
newtreatmentname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
treatmentID = getTreatmentID(newtreatmentname,experimentname,cropname)
# Treatment with this name does not exist, so we can insert it
@@ -952,7 +946,7 @@ def check_and_delete_operationDB(op_id,op_name):
op_name = operation name
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c.execute("delete from operations where opID=?",(op_id,))
if(op_name == "Simulation Start"):
@@ -997,7 +991,7 @@ def check_and_update_operationDB(op_id,treatmentname, experimentname, cropname,
#print("fertNut_record=",fertNut_record)
#print("PGR_record=",PGR_record)
#print("SR_record=",SR_record)
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
op_id = int(op_id)
# If op_id=-10, it means it is a new operation record so we need to find treatment id and experiment id
@@ -1081,7 +1075,7 @@ def validate_date(o_t_exid,op_name,date):
date
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
err_string = ""
date = dt.strptime(date,"%m/%d/%Y")
@@ -1138,7 +1132,7 @@ def getme_date_of_first_operationDB(treatmentname, experimentname ,cropname):
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
search_str0 = treatmentname
search_str1 = experimentname
@@ -1174,7 +1168,7 @@ def read_operation_timeDB2(operationname, treatmentname, experimentname ,cropnam
operationname date info
'''
rtuple =()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
record_tuple =(treatmentname,experimentname,cropname)
check_str = re.sub(' ','',operationname)
@@ -1214,7 +1208,7 @@ def readOpDetails(operationid, operationName):
tuple with operation info
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#search and extract
record_tuple = operationid,
@@ -1259,7 +1253,7 @@ def read_treatmentDB(crop,experiment):
return treatment name
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
record_tuple = (experiment, crop)
c1 = c.execute("SELECT name FROM treatment where t_exid = (select exid from experiment where name = ? and crop = ?)",record_tuple)
@@ -1281,7 +1275,7 @@ def read_operationsDB(crop,eitem,titem):
Tuple with complete operation information sorted by date in ascending order
'''
rlist =[] # list
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(eitem) > 0:
c1 = c.execute("SELECT name, odate, opID, DATE(year||'-'||month||'-'||day) as dt_frmtd \
@@ -1310,7 +1304,7 @@ def read_fertilizationClass():
Fertilization list.
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT fertilizationClass from fertilizationClass order by fertilizationClass")
c1_row = c1.fetchall()
@@ -1330,7 +1324,7 @@ def read_FaqDB(tabname,cropname):
Tuple with FAQ information for a particular tab.
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if tabname == None:
c1= c.execute("SELECT id, tabname, question, answer FROM Faq")
@@ -1357,7 +1351,7 @@ def read_sitedetailsDB():
Tuple with sitenames list.
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1= c.execute("SELECT id, sitename FROM sitedetails order by lower(sitename)")
c1_row = c1.fetchall()
@@ -1377,7 +1371,7 @@ def read_soilOMDB(soilname):
Tuple with soil information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select rowid, Sand, Silt, Clay, BD, OM_pct, TH33, TH1500 FROM soil_long where o_sid = (SELECT id FROM soil \
@@ -1399,7 +1393,7 @@ def read_soilhydroDB(soilname):
Tuple with soil information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select thr, ths, tha, th, Alfa, n, Ks, Kk, thk, BD, OM_pct, Sand, Silt FROM soil_long where o_sid = \
@@ -1420,7 +1414,7 @@ def insert_into_soillong(soilname,soilrow):
soilrow = tuple with soil information to be ingested on soil_long table
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT id FROM soil where soilname=?",(soilname,))
c1_row = c1.fetchall()
@@ -1444,7 +1438,7 @@ def read_soillongDB(soilname):
Output:
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select Bottom_depth,OM_pct,NO3,NH4,HnNew,initType,Tmpr,Sand,Silt,Clay,BD,TH33,TH1500,thr,ths,tha,th,Alfa,n,Ks,\
@@ -1466,7 +1460,7 @@ def getSiteFromSoilname(soilname):
Output:
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("select sitename from soil so, sitedetails si where so.site_id = si.id and soilname=?",[soilname])
@@ -1487,7 +1481,7 @@ def read_soilshortDB(soilname):
Tuple with soil information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select Bottom_depth,initType,OM_pct,NO3,NH4,HnNew,Tmpr,Sand,Silt,Clay,BD,TH33,TH1500,thr,ths,tha,th,Alfa,n,Ks,Kk,thk,CO2,O2 FROM soil_long \
@@ -1510,7 +1504,7 @@ def read_soiltextureDB(soilname):
Tuple with soil information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select Sand,Silt,Clay FROM soil_long where o_sid = (SELECT id FROM soil where soilname = ? )",[soilname])
@@ -1530,7 +1524,7 @@ def read_gasDB():
Tuple with gas information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1= c.execute("Select name,EPSI,bTort,Diffusion_Coeff FROM gas order by id")
c1row = c1.fetchall()
@@ -1551,7 +1545,7 @@ def read_soilnitrogenDB(soilname):
Tuple with soil information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select kh,kL,km,kn,kd,fe,fh,r0,rL,rm,fa,nq,cs FROM soil_long where o_sid = (SELECT id FROM soil where \
@@ -1573,7 +1567,7 @@ def read_soluteDB(id=1): #
Tuple with solute information
'''
rtuple = ()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if isinstance(id, int):
c1= c.execute("Select name,EPSI,IUPW,CourMax,Diffusion_Coeff FROM solute where id = ? ",[id])
@@ -1593,7 +1587,7 @@ def read_dispersivityDB(texture): #
Tuple with dispersivity information
'''
rtuple = ()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if texture != "":
query = "Select alpha FROM dispersivity where texturecl like '%" + texture + "%'"
@@ -1614,7 +1608,7 @@ def read_soillongDB_maxdepth(soilname):
Tuple with max Bottom_depth
'''
rlist = 0 #[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select max(Bottom_depth) FROM soil_long where o_sid = (SELECT id FROM soil where soilname = ? )",[soilname])
@@ -1632,7 +1626,7 @@ def delete_soillong(soilname):
soilname
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1= c.execute("Select o_sid, id from soil_long where o_sid = (Select id FROM soil where soilname =? ORDER by id ASC)",[soilname])
c1row = c1.fetchall()
@@ -1652,7 +1646,7 @@ def insert_soilgridratioDB(soilgrid_tuple):
Output:
next_gridratio_id
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#find what would be the id for next entry inside the gridratio table
c1= c.execute("Select max(gridratio_id) FROM gridratio")
@@ -1676,7 +1670,7 @@ def updateBottomBC(soilname,bottomBCVal):
bottomBCVal
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT o_gridratio_id FROM soil where soilname=?",(soilname,))
c1_row = c1.fetchone()
@@ -1698,7 +1692,7 @@ def check_soilDB(soilname,site_id):
id = soil id
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
soiltuple = (soilname,site_id)
c1= c.execute("SELECT id FROM soil where soilname=? and site_id=?",soiltuple)
@@ -1725,7 +1719,7 @@ def check_and_insert_soilDB(soilname,site_id,gridratio_id):
###if rlist !=0:
#print("rlist=",rlist)
if rlist == []:
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1= c.execute("insert into soil (soilname, site_id, o_gridratio_id) values (?,?,?)",soiltuple)
conn.commit()
@@ -1743,7 +1737,7 @@ def read_soilDB():
Tuple with soil id and name
'''
rlist = [] #list
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT id, soilname FROM soil order by lower(soilname)")
c1_row = c1.fetchall()
@@ -1764,7 +1758,7 @@ def read_soilgridratioDB(soilname):
Tuple with gridratio information
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(soilname) > 0:
c1= c.execute("Select SR1,SR2,IR1,IR2,PlantingDepth,XLimitRoot,BottomBC,GasBCTop,GasBCBottom FROM gridratio where gridratio_id = (SELECT \
@@ -1785,7 +1779,7 @@ def read_biologydefault():
Tuple with biologydefault information
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT dthH, dthL, es, Th_m, tb, QT, dThD, Th_d FROM biologydefault")
c1_row = c1.fetchall()
@@ -1805,7 +1799,7 @@ def read_experiment(item):
Tuple with experiment name and id list
'''
rlist =[]
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
search_str = item
if len(search_str) > 0:
@@ -1828,7 +1822,7 @@ def getMulchGeo(nutrient):
Tuple with mulch geo information
'''
rlist =()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("select minHoriSize,diffusionRestriction,longWaveRadiationCtrl,decompositionCtrl,deltaRShort,deltaRLong, \
omega,epsilonMulch,alphaMulch,maxStepInPicardIteration,toleranceHead,rhoMulch,poreSpace,maxPondingDepth \
@@ -1850,7 +1844,7 @@ def getMulchDecomp(nutrient):
Tuple with mulch decomp information
'''
rlist =()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("select contactFraction,alphaFeeding,carbMass,cellMass,lignMass,carbNMass, \
cellNMass,lignNMass,carbDecomp,cellDecomp,lignDecomp from mulchDecomp where \
@@ -1872,7 +1866,7 @@ def read_weather_id_forstationtype(stationtype):
Tuple with weather id list
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT distinct weather_id FROM weather_data where stationtype = ? order by lower(weather_id)",(stationtype,))
c1_row = c1.fetchall()
@@ -1893,7 +1887,7 @@ def read_weatheryears_fromtreatment(treatment):
Tuple with operation date list
'''
rlist = [] # list {} # dictionary
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
experiment_name = treatment.split('/')[1]
treatment_name = treatment.split('/')[2]
@@ -1918,7 +1912,7 @@ def read_weatherdate_fromtreatment(treatment):
Tuple with operation date list
'''
rlist = []
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
crop_name = treatment.split('/')[0]
experiment_name = treatment.split('/')[1]
@@ -1945,7 +1939,7 @@ def read_weather_metaDBforsite(site):
Tuple with id and stationtype list
'''
rlist ={} # dictionary
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if len(site) > 0:
c1 = c.execute("SELECT id, stationtype FROM weather_meta where site=? order by lower(stationtype)",[site])
@@ -1966,7 +1960,7 @@ def read_weather_metaDB():
Tuple with id and stationtype list
'''
rlist ={}
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
c1 = c.execute("SELECT id, stationtype FROM weather_meta order by lower(stationtype)")
c1_row = c1.fetchall()
@@ -1987,7 +1981,7 @@ def read_weatherlongDB(stationtype):
Tuple with complete weather_meta information
'''
rlist =()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
#print("Debug: stationtype=",stationtype)
c1 = c.execute("Select rlat,rlon,Bsolar,Btemp,Atemp,BWInd,BIR,AvgWind,AvgRainRate,ChemCOnc,AvgCO2,stationtype,site FROM weather_meta wm, sitedetails s \
@@ -2008,7 +2002,7 @@ def insert_update_weather(record_tuple,buttontext):
buttontext = save or update
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if buttontext.find('SaveAs')==0:
c.execute("insert into weather_meta (Bsolar,Btemp,Atemp,BWInd,BIR,AvgWind,AvgRainRate,ChemCOnc,AvgCO2,site,stationtype) values (?,?,?,?,?,?,?,?,?,?,?)",record_tuple)
@@ -2028,7 +2022,7 @@ def delete_weather(site,stationtype):
stationtype
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
weathertuple = (stationtype,site)
c.execute("delete from weather_meta where stationtype=? and site=?",weathertuple)
@@ -2048,7 +2042,7 @@ def delete_cultivar(crop,cultivarname):
delete_flag = messageUserDelete("Are you sure you want to delete this record?")
if delete_flag:
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if crop == "maize":
c.execute("delete from cultivar_maize where hybridname=?",[cultivarname])
@@ -2072,7 +2066,7 @@ def insertUpdateCultivarMaize(record_tuple,buttontext):
buttontext = Save/update
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if buttontext == "SaveAs":
qstatus = c.execute("insert into cultivar_maize (hybridname,juvenileleaves,DaylengthSensitive,Rmax_LTAR,Rmax_LTIR,PhyllFrmTassel,StayGreen,\
@@ -2097,7 +2091,7 @@ def insertUpdateCultivarPotato(record_tuple,buttontext):
buttontext = Save/update
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if buttontext == "SaveAs":
qstatus = c.execute("insert into cultivar_potato (hybridname,A1,A6,A8,A9,A10,G1,G2,G3,G4,RRRM,RRRY,RVRL,ALPM,ALPY,RTWL,\
@@ -2122,7 +2116,7 @@ def insertUpdateCultivarSoybean(record_tuple,buttontext):
buttontext = Save/update
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if buttontext == "SaveAs":
qstatus = c.execute("insert into cultivar_soybean (hybridname,matGrp,seedLb,fill,v1,v2,v3,r1,r2,r3,r4,r5,r6,\
@@ -2152,7 +2146,7 @@ def insertUpdateCultivarCotton(record_tuple,buttontext):
buttontext = Save/update
Output:
'''
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
if buttontext == "SaveAs":
qstatus = c.execute("insert into cultivar_cotton (hybridname,calbrt11,calbrt12,calbrt13,calbrt15,calbrt16,\
@@ -2183,7 +2177,7 @@ def extract_cropOutputData(tablename,simulationname):
Output:
dataframe with output information
'''
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
query = "select * from " + tablename + " where " + tablename + "_id=" + simulationname
if tablename == "g01_potato":
@@ -2204,7 +2198,7 @@ def delete_cropOutputSim(id,crop):
crop
Output:
'''
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
#print("crop=",crop)
if crop == "maize":
@@ -2239,7 +2233,7 @@ def readSoilInfoCropOutputDB(crop,tablename,simulationname):
Output:
dataframe with output information
'''
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
if tablename == "g03_maize" or tablename == "g03_fallow" or tablename == "g03_soybean" or tablename == "g03_potato" or tablename == "g03_cotton":
query = "select Date_Time, X, Y, hNew, abs(hNew) as absHNew, thNew, hNew/abs(hNew) as mult, NO3N, NH4N, Temp from " + tablename + " where " + tablename + "_id=" + simulationname
@@ -2319,7 +2313,7 @@ def ingestOutputFile(table_name,g_name,simulationname):
simulationname
Output:
'''
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
id = table_name + "_id"
g_df = pd.read_csv(g_name,skipinitialspace=True,index_col=False)
@@ -2374,7 +2368,7 @@ def ingestGeometryFile(grdFile,g03File,simulation):
simulationname
Output:
'''
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
# First read the .grd file
# Find line where this string is located, we don't want to read anything from this line on.
@@ -2417,7 +2411,7 @@ def readGeometrySimID(simulationname):
Output:
dataframe with output information
'''
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
query = "select X, Y, Layer, Area from geometry where simID = " + simulationname
df = pd.read_sql_query(query,conn)
@@ -2436,7 +2430,7 @@ def getMaizeDateByDev(sim_id,maizePhase):
'''
rlist = ""
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
maizetuple = (sim_id,maizePhase)
c2 = c.execute("select min(Date_Time) from g01_maize where g01_maize_id=? and Note=?",maizetuple)
@@ -2462,7 +2456,7 @@ def getMaxDateG01BySimID(crop, sim_id):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
query = "select max(Date_Time) from g01_" + crop + " where g01_" + crop + "_id=" + sim_id
c2 = c.execute(query)
@@ -2484,7 +2478,7 @@ def getTuberInitDate(sim_id):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
c2 = c.execute("select min(Date_Time) from g01_potato where (tuberDM > 0 or Stage > 2.01) and g01_potato_id=?",[sim_id])
c2_row = c2.fetchone()
@@ -2508,7 +2502,7 @@ def getMaturityDate(sim_id):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
c2 = c.execute("select min(Date_Time) from g01_potato where Stage > 10 and g01_potato_id=?",[sim_id])
c2_row = c2.fetchone()
@@ -2535,7 +2529,7 @@ def getPotatoAgronomicData(sim_id, date):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
harvestDate = dt.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d')
querytuple = (sim_id,harvestDate+'%')
@@ -2562,7 +2556,7 @@ def getMaizeAgronomicData(sim_id, date):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
harvestDate = dt.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d')
querytuple = (sim_id,harvestDate+'%')
@@ -2589,7 +2583,7 @@ def getCottonAgronomicData(sim_id):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
querytuple = (sim_id,)
@@ -2613,7 +2607,7 @@ def getCottonDevDate(sim_id, stage):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
query = "select max(Date_time), Note from g01_cotton where Note like '" + stage + "%' and g01_cotton_id=" + sim_id
@@ -2640,7 +2634,7 @@ def getSoybeanDevDate(sim_id, rstage):
'''
rlist = None # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
querytuple = (rstage,sim_id)
@@ -2669,7 +2663,7 @@ def getSoybeanAgronomicData(sim_id, date):
'''
rlist = None
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
harvestDate = dt.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d')
querytuple = (sim_id,harvestDate+'%')
@@ -2706,7 +2700,7 @@ def getEnvironmentalData(sim_id, date, crop):
'''
rlist = None
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
if crop == "maize" or crop == "soybean" or crop == "potato":
maturityDate = dt.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d')
@@ -2740,7 +2734,7 @@ def getNitrogenUptake(sim_id, date, crop):
'''
rlist = None
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
harvestDate = dt.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d')
querytuple = (sim_id,harvestDate+'%')
@@ -2772,7 +2766,7 @@ def getNitroWaterStressDates(sim_id):
rlist = [] # list
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
c1 = c.execute("select distinct Date_Time, PSIEffect_leaf, NEffect_leaf, PSIEffect_Pn, NEffect_Pn from plantStress_potato where \
(PSIEffect_leaf <= 0.75 or NEffect_leaf <= 0.75 or PSIEffect_Pn <= 0.75 or NEffect_Pn <= 0.75) and \
@@ -2802,7 +2796,7 @@ def getMaizePlantStressDates(sim_id):
rlist = []
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
c1 = c.execute("select distinct Date_Time, waterstress, N_stress, Shade_Stress, PotentialArea from plantStress_maize where \
(waterstress >= 0.25 or N_stress >= 0.25 or Shade_Stress >= 0.25 or PotentialArea >= 0.25) and \
@@ -2832,7 +2826,7 @@ def getSoybeanPlantStressDates(sim_id):
rlist = []
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
c1 = c.execute("select distinct ps.Date_Time, ps.wstress, ps.Nstress, ps.Cstress, g1.'Limit' from plantStress_soybean ps, \
g01_soybean g1 where (ps.wstress <= 0.75 or ps.Nstress <= 0.75 or ps.Cstress <= 0.75) and \
@@ -2863,7 +2857,7 @@ def getCottonPlantStressDates(sim_id):
'''
rlist = []
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
if c:
c1 = c.execute("select distinct Date_Time, W_stress, N_Veg_Str, N_Fru_Str, N_Rt_Str, C_Stress from plantStress_cotton where \
(W_stress<0.8 or N_Veg_Str<0.8 or N_Fru_Str<0.8 or N_Rt_Str<0.8 or C_Stress<0.8) and \
diff --git a/Classim/TabbedDialog/CultivarTab.py b/Classim/TabbedDialog/CultivarTab.py
index 1a2377d..654dee2 100644
--- a/Classim/TabbedDialog/CultivarTab.py
+++ b/Classim/TabbedDialog/CultivarTab.py
@@ -1,6 +1,6 @@
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QTreeWidgetItem, QWidget, QLabel, QHBoxLayout, QComboBox, QVBoxLayout, QPushButton, QSpacerItem, \
- QSizePolicy, QRadioButton, QButtonGroup, QScrollArea, QGridLayout, QCheckBox
+ QSizePolicy, QRadioButton, QButtonGroup, QScrollArea, QGridLayout, QCheckBox, QHeaderView
from PyQt5.QtCore import pyqtSlot
from CustomTool.custom1 import *
from CustomTool.UI import *
@@ -11,11 +11,8 @@
import re
'''
-Contains 2 classes.
-1). Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the
- tab classes. In future,we can centralize it. Lower priority.
-
-2). Class Cultivar_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget.
+Contains 1 Class.
+1). Class Cultivar_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget.
It handles all the features of Cultivar Tab on the interface. It has signal slot mechanism. It
interact with the DatabaseSys\Databasesupport.py for all the databases related task.
Pretty generic and self explanotory methods.
@@ -25,26 +22,6 @@
Left panel does the heavy lifting and interacts with user.
Right panel is mainly for frequently asked questions (FAQ) stored in sqlite table "Faq".
'''
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
#this is widget of type 1. It would be added to as a tab
class Cultivar_Widget(QWidget):
@@ -58,12 +35,12 @@ def init_ui(self):
self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.tab_summary = QTextEdit("")
@@ -664,6 +641,11 @@ def showcultivarcombo(self):
for key in cultivarlists:
self.cultivarcombo.addItem(cropname + ":" + str(key))
self.cultivarcombo.currentIndexChanged.connect(self.showcultivardetailscombo)
+
+ if self.helpcheckbox.isChecked():
+ self.importfaq("cultivar")
+ self.faqtree.setVisible(True)
+
return True
diff --git a/Classim/TabbedDialog/ManagementTab.py b/Classim/TabbedDialog/ManagementTab.py
index 639aa83..58cca70 100644
--- a/Classim/TabbedDialog/ManagementTab.py
+++ b/Classim/TabbedDialog/ManagementTab.py
@@ -7,28 +7,6 @@
from TabbedDialog.tableWithSignalSlot import *
from CustomTool.createManRepWindow import *
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
- #print("text=", text)
- document = QtGui.QTextDocument()
- document.setHtml(text)
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.green))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
-
-
-#this is widget of type 1. It would be added to as a tab
class ManagementTab_Widget(QWidget):
def __init__(self):
super(ManagementTab_Widget,self).__init__()
@@ -37,16 +15,16 @@ def __init__(self):
def init_ui(self):
self.setGeometry(QtCore.QRect(10,20,700,700))
- self.setFont(QtGui.QFont("Calibri",10))
+ self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
self.importfaq("management")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.mainlayout1 = QGridLayout()
diff --git a/Classim/TabbedDialog/OutputTab.py b/Classim/TabbedDialog/OutputTab.py
index 8f63dc9..6f4eb3e 100644
--- a/Classim/TabbedDialog/OutputTab.py
+++ b/Classim/TabbedDialog/OutputTab.py
@@ -10,12 +10,14 @@
from time import mktime
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QWidget, QTabWidget, QLabel, QHBoxLayout, QTableWidget, QTableWidgetItem, QComboBox, QVBoxLayout, QPushButton, \
- QSpacerItem, QSizePolicy, QHeaderView, QRadioButton, QButtonGroup, QFormLayout, QScrollArea, QCheckBox, QGridLayout, QGroupBox
+ QSpacerItem, QSizePolicy, QHeaderView, QRadioButton, QButtonGroup, QFormLayout, QScrollArea, QCheckBox, QGridLayout, \
+ QHeaderView, QGroupBox
from CustomTool.custom1 import *
from CustomTool.UI import *
from DatabaseSys.Databasesupport import *
from Models.cropdata import *
from TabbedDialog.tableWithSignalSlot import *
+from CustomTool.getClassimDir import *
from CustomTool.genDictOutput import *
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
@@ -25,65 +27,24 @@
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
-global app_dir
+global classimDir
+global runDir
global index
pd.options.mode.chained_assignment = None
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-app_dir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(app_dir):
- os.makedirs(app_dir)
-
-run_dir = os.path.join(app_dir,'run')
-if not os.path.exists(run_dir):
- os.makedirs(run_dir)
+classimDir = getClassimDir()
+runDir = os.path.join(classimDir,'run')
'''
-Contains 3 classes.
-1). Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the tab classes.
- In future,we can centralize it. Lower priority.
-
-2). Class Output_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget. It handles
+Contains 1 classes.
+1). Class Output_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget. It handles
all the features of OUTPUT Tab on the interface. It has signal slot mechanism. It does interact with the
DatabaseSys\Databasesupport.py for all the databases related task.
Pretty generic and self explanotory methods.
Refer baseline classes at http://pyqt.sourceforge.net/Docs/PyQt5/QtWidgets.html#PyQt5-QtWidgets
-
-3). Class TimeAxisItem formats the date that is displayed on the x-axis.
'''
-
-
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
-
-class TimeAxisItem(pg.AxisItem):
- def tickStrings(self, values, scale, spacing):
- # return [date.fromtimestamp(value).strftime('%m/%d/%y') for value in values]
- return [date.fromtimestamp(value).strftime('%m/%d') for value in values]
-
-
-#this is widget of type 1. It would be added to as a tab
class Output2_Widget(QWidget):
# Add a signal
def __init__(self):
@@ -93,20 +54,17 @@ def __init__(self):
def init_ui(self):
self.setGeometry(QtCore.QRect(10,20,700,700))
- self.setAccessibleName("output2")
- self.setFont(QtGui.QFont("Calibri",10))
+ self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
self.importfaq("output")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
- self.status2 = QTextEdit("Status.")
- self.status2.setReadOnly(True)
- self.status2.setVisible(False)
- self.status2.setFrameShape(QtWidgets.QFrame.NoFrame)
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
+ self.faqtree.setVisible(False)
self.tab_summary = QTextEdit("Choose simulation by checking from the list box. Simulation outputs are \
categorized into 5 types and are displayed individually in bottom tabbed panel.")
@@ -548,7 +506,7 @@ def on_deletebuttonclick(self):
self.cropname = self.table2.item(self.rowNumChecked,5).text().split('/')[0]
# First delete the directory that was creates with the simulation information
- sim_dir = os.path.join(run_dir,self.simulationID)
+ sim_dir = os.path.join(runDir,self.simulationID)
shutil.rmtree(sim_dir, ignore_errors=True)
# Delete simulation from pastruns
@@ -929,8 +887,9 @@ def on_click_table_widget(self):
########## plantTab ##########
# Creates dictionaries based on crop type
self.varDescDict, self.varDescUnitDict, self.varFuncDict = genDictOutput(cropArr,"plant",0)
- dateAxis = TimeAxisItem(orientation='bottom')
- self.plantGraphWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis,'units':None,'unitPrefix':None})
+ #dateAxis = TimeAxisItem(orientation='bottom')
+ dateAxis = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
+ self.plantGraphWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis})
if self.cropname != "fallow":
self.plantTab.groupBox = QGroupBox("Select parameter to plot")
self.leftBoxLayout = QGridLayout()
@@ -962,7 +921,7 @@ def on_click_table_widget(self):
# Creates dictionaries based on crop type
self.varSoilCNDescDict, self.varSoilCNDescUnitDict, self.varSoilCNFuncDict = genDictOutput(cropArr,"soilCN",0)
- dateAxis = TimeAxisItem(orientation='bottom')
+ dateAxis = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.soilCNWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis})
self.soilCNTab.groupBox = QGroupBox("Select parameter to plot")
self.leftBoxLayout = QGridLayout()
@@ -1033,22 +992,22 @@ def on_click_table_widget(self):
self.SoilTSGraphWidget = pg.GraphicsLayoutWidget()
- dateAxisTotWatProf = TimeAxisItem(orientation='bottom')
+ dateAxisTotWatProf = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.totWaterProfilePlot = self.SoilTSGraphWidget.addPlot(row=0,col=0,title="Total Water for Entire Profile (mm)",axisItems = {'bottom':dateAxisTotWatProf,'unitPrefix':None})
- dateAxisTotWatLayer = TimeAxisItem(orientation='bottom')
+ dateAxisTotWatLayer = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.totWaterLayerPlot = self.SoilTSGraphWidget.addPlot(row=0,col=1,title="Total Water by Layer (mm)",axisItems = {'bottom':dateAxisTotWatLayer,'unitPrefix':None})
- dateAxisWaterContLayer = TimeAxisItem(orientation='bottom')
+ dateAxisWaterContLayer = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.waterContentLayerPlot = self.SoilTSGraphWidget.addPlot(row=0,col=2,title="Water Content by Layer (cm3/cm3)",axisItems = {'bottom':dateAxisWaterContLayer,'unitPrefix':None})
- dateAxisNNO3ConcProf = TimeAxisItem(orientation='bottom')
+ dateAxisNNO3ConcProf = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.NNO3ConcProfilePlot = self.SoilTSGraphWidget.addPlot(row=1,col=0,title="Total NNO3 as Nitrogen for Entire Profile (kg/ha)",axisItems = {'bottom':dateAxisNNO3ConcProf,'unitPrefix':None})
- dateAxisNNO3ConcLayer = TimeAxisItem(orientation='bottom')
+ dateAxisNNO3ConcLayer = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.NNO3ConcLayerPlot = self.SoilTSGraphWidget.addPlot(row=1,col=1,title="Total NNO3 as Nitrogen by Layer (kg/ha)",axisItems = {'bottom':dateAxisNNO3ConcLayer,'unitPrefix':None})
- dateAxisTemp = TimeAxisItem(orientation='bottom')
+ dateAxisTemp = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.tempPlot = self.SoilTSGraphWidget.addPlot(row=1,col=2,title="Temperature by Layer (oC)",axisItems = {'bottom':dateAxisTemp,'unitPrefix':None})
self.soilTSTab.mainlayout = QHBoxLayout()
@@ -1262,7 +1221,7 @@ def on_click_table_widget(self):
# Creates dictionaries based on crop type
self.varSurfChaDescDict, self.varSurfChaDescUnitDict, self.varSurfChaFuncDict = genDictOutput(cropArr,"surfCha",0)
- dateAxis = TimeAxisItem(orientation='bottom')
+ dateAxis = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.surfChaGraphWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis})
self.surfChaTab.groupBox = QGroupBox("Select parameter to plot")
diff --git a/Classim/TabbedDialog/RotOutputTab.py b/Classim/TabbedDialog/RotOutputTab.py
index 996791a..52d5901 100644
--- a/Classim/TabbedDialog/RotOutputTab.py
+++ b/Classim/TabbedDialog/RotOutputTab.py
@@ -9,7 +9,8 @@
from time import mktime
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QWidget, QTabWidget, QLabel, QHBoxLayout, QTableWidget, QTableWidgetItem, QComboBox, QVBoxLayout, QPushButton, \
- QSpacerItem, QSizePolicy, QHeaderView, QRadioButton, QButtonGroup, QFrame, QFormLayout, QScrollArea, QCheckBox, QGridLayout, QGroupBox
+ QSpacerItem, QSizePolicy, QHeaderView, QRadioButton, QButtonGroup, QFrame, QFormLayout, QScrollArea, QCheckBox, \
+ QGridLayout, QGroupBox, QHeaderView
from CustomTool.custom1 import *
from CustomTool.UI import *
from DatabaseSys.Databasesupport import *
@@ -25,25 +26,15 @@
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
-global app_dir
-global index
+global classimDir
+global runDir
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-app_dir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(app_dir):
- os.makedirs(app_dir)
-
-run_dir = os.path.join(app_dir,'run')
-if not os.path.exists(run_dir):
- os.makedirs(run_dir)
+classimDir = getClassimDir()
+runDir = os.path.join(classimDir,'run')
'''
-Contains 2 classes.
-1). Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the tab classes.
- In future,we can centralize it. Lower priority.
-
-2). Class Output_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget. It handles
+Contains 1 class.
+1). Class Output_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget. It handles
all the features of OUTPUT Tab on the interface. It has signal slot mechanism. It does interact with the
DatabaseSys\Databasesupport.py for all the databases related task.
Pretty generic and self explanotory methods.
@@ -59,33 +50,6 @@
'''
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
-
-class TimeAxisItem(pg.AxisItem):
- def tickStrings(self, values, scale, spacing):
- return [date.fromtimestamp(value).strftime('%m/%d') for value in values]
-
-
-#this is widget of type 1. It would be added to as a tab
class RotOutput_Widget(QWidget):
# Add a signal
def __init__(self):
@@ -95,20 +59,17 @@ def __init__(self):
def init_ui(self):
self.setGeometry(QtCore.QRect(10,20,700,700))
- self.setAccessibleName("rotation_output")
- self.setFont(QtGui.QFont("Calibri",10))
+ self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
self.importfaq("output")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
- self.status2 = QTextEdit("Status.")
- self.status2.setReadOnly(True)
- self.status2.setVisible(False)
- self.status2.setFrameShape(QtWidgets.QFrame.NoFrame)
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
+ self.faqtree.setVisible(False)
self.tab_summary = QTextEdit("Choose rotation by checking from the list box.")
self.tab_summary.setReadOnly(True)
@@ -601,7 +562,7 @@ def on_deletebuttonclick(self):
self.rotationID = self.table2.simGrp.buttons()[self.rowNumChecked].text()
self.cropname = self.table2.item(self.rowNumChecked,6).text().split('/')[0]
- delete_pastrunsDB_rotationID(self.rotationID,run_dir,self.cropname)
+ delete_pastrunsDB_rotationID(self.rotationID,runDir,self.cropname)
self.populate()
@@ -830,7 +791,7 @@ def on_click_table_widget(self):
self.simSummaryAgroData = "Simulation Agronomic Data at
" + HarvestDate + " (harvest date)"
self.simSummaryAgroData += "
Yield: " + '{:3.2f}'.format(agroDataTuple[0]*plantDensity*10) + " kg/ha"
self.simSummaryAgroData += "
Total biomass: " + '{:3.2f}'.format(agroDataTuple[1]*plantDensity*10) + " kg/ha"
- self.simSummaryAgroData += "
Nitrogen Uptake: " + '{:3.2f}'.format(NitrogenUptakeTuple[0]*10) + " kg/ha"
+ self.simSummaryAgroData += "
Nitrogen Uptake: " + '{:3.2f}'.format(NitrogenUptakeTuple[0]/10) + " kg/ha"
self.simSummaryAgroData += "
Transpiration: " + '{:3.2f}'.format(agroDataTuple[2]*plantDensity/1000) + " mm"
elif self.cropArr[runNum] == "maize":
if(MaturityDate != "N/A"):
@@ -909,7 +870,7 @@ def on_click_table_widget(self):
# Creates dictionaries based on crop type
self.finalVarDescDict, self.finalVarDescUnitDict, self.finalVarFuncDict = genDictOutput(self.cropArr,"plant",1)
- dateAxis = TimeAxisItem(orientation='bottom')
+ dateAxis = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.plantGraphWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis})
self.plantTab.groupBox = QGroupBox("Select parameter to plot")
self.leftBoxLayout = QGridLayout()
@@ -945,7 +906,7 @@ def on_click_table_widget(self):
# Creates dictionaries based on crop type
self.finalSoilCNVarDescDict, self.finalSoilCNVarDescUnitDict, self.finalSoilCNVarFuncDict = genDictOutput(self.cropArr,"soilCN",1)
- dateAxis = TimeAxisItem(orientation='bottom')
+ dateAxis = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.soilCNWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis})
self.soilCNTab.groupBox = QGroupBox("Select parameter to plot")
self.leftBoxLayout = QGridLayout()
@@ -1022,22 +983,22 @@ def on_click_table_widget(self):
self.SoilTSGraphWidget = pg.GraphicsLayoutWidget()
- dateAxisTotWatProf = TimeAxisItem(orientation='bottom')
+ dateAxisTotWatProf = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.totWaterProfilePlot = self.SoilTSGraphWidget.addPlot(row=0,col=0,title="Total Water for Entire Profile (mm)",axisItems = {'bottom':dateAxisTotWatProf,'unitPrefix':None})
- dateAxisTotWatLayer = TimeAxisItem(orientation='bottom')
+ dateAxisTotWatLayer = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.totWaterLayerPlot = self.SoilTSGraphWidget.addPlot(row=0,col=1,title="Total Water by Layer (mm)",axisItems = {'bottom':dateAxisTotWatLayer,'unitPrefix':None})
- dateAxisWaterContLayer = TimeAxisItem(orientation='bottom')
+ dateAxisWaterContLayer = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.waterContentLayerPlot = self.SoilTSGraphWidget.addPlot(row=0,col=2,title="Water Content by Layer (cm3/cm3)",axisItems = {'bottom':dateAxisWaterContLayer,'unitPrefix':None})
- dateAxisNNO3ConcProf = TimeAxisItem(orientation='bottom')
+ dateAxisNNO3ConcProf = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.NNO3ConcProfilePlot = self.SoilTSGraphWidget.addPlot(row=1,col=0,title="Total NNO3 as Nitrogen for Entire Profile (kg/ha)",axisItems = {'bottom':dateAxisNNO3ConcProf,'unitPrefix':None})
- dateAxisNNO3ConcLayer = TimeAxisItem(orientation='bottom')
+ dateAxisNNO3ConcLayer = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.NNO3ConcLayerPlot = self.SoilTSGraphWidget.addPlot(row=1,col=1,title="Total NNO3 as Nitrogen by Layer (kg/ha)",axisItems = {'bottom':dateAxisNNO3ConcLayer,'unitPrefix':None})
- dateAxisTemp = TimeAxisItem(orientation='bottom')
+ dateAxisTemp = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.tempPlot = self.SoilTSGraphWidget.addPlot(row=1,col=2,title="Temperature by Layer (oC)",axisItems = {'bottom':dateAxisTemp,'unitPrefix':None})
self.soilTSTab.mainlayout = QHBoxLayout()
@@ -1082,7 +1043,7 @@ def on_click_table_widget(self):
t3['Y'] = maxY-t3['Y']
# Need to get layers from soil_long table
- connCrop, cCrop = openDB(dbDir + '\\crop.db')
+ connCrop, cCrop = openDB('crop.db')
querySL = "select Bottom_depth as Y from soil_long where o_sid = (select id from soil where soilname = '" + self.soilname + "')"
tSL = pd.read_sql_query(querySL,connCrop)
tSL = tSL.reset_index()
@@ -1275,7 +1236,7 @@ def on_click_table_widget(self):
# Creates dictionaries based on crop type
self.varSurfChaDescDict, self.varSurfChaDescUnitDict, self.varSurfChaFuncDict = genDictOutput(self.cropArr,"surfCha",1)
- dateAxis = TimeAxisItem(orientation='bottom')
+ dateAxis = pg.graphicsItems.DateAxisItem.DateAxisItem(orientation = 'bottom')
self.surfChaGraphWidget = pg.PlotWidget(axisItems = {'bottom':dateAxis})
self.surfChaTab.groupBox = QGroupBox("Select parameter to plot")
diff --git a/Classim/TabbedDialog/RotationTab.py b/Classim/TabbedDialog/RotationTab.py
index ebe0274..f8d6bc4 100644
--- a/Classim/TabbedDialog/RotationTab.py
+++ b/Classim/TabbedDialog/RotationTab.py
@@ -5,87 +5,46 @@
import sys
import re
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QTableWidget, QTableWidgetItem, QComboBox, QVBoxLayout, QPushButton, QSpacerItem, QSizePolicy, \
- QHeaderView, QRadioButton, QButtonGroup, QMenu, QCheckBox, QGridLayout, QGroupBox
+ QHeaderView, QRadioButton, QButtonGroup, QMenu, QCheckBox, QGridLayout, QGroupBox, QHeaderView
from PyQt5.QtCore import QFile, QTextStream, pyqtSignal, QCoreApplication
from CustomTool.custom1 import *
from CustomTool.UI import *
from CustomTool.generateModelInputFiles import *
+from CustomTool.getClassimDir import *
from DatabaseSys.Databasesupport import *
from Models.cropdata import *
from TabbedDialog.tableWithSignalSlot import *
from subprocess import Popen
-global runpath1
-global app_dir
-global repository_dir
-
-#----------------------
-# at some point in the future we will have to figure out a solution of alternative documents folders
-#import winreg as wr
-#Registry = wr.ConnectRegistry(None, wr.HKEY_CURRENT_USER) # get a handle to the HKEY_CURRENT_USER branch in registry
-#RawKey = wr.OpenKey(Registry, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") # get a handle to the key we need
-#newPath=wr.QueryValueEx(RawKey,r"Personal") # retrieve a tuple with the information for the value of 'Personal'
-#gparent_dir=newPath[0] #0 is the directory name
-# this is gparent_dir
-#----------------
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-app_dir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(app_dir):
- os.makedirs(app_dir)
-
-global db
-db = app_dir+'\\crop.db'
+global classimDir
+global runDir
+global storeDir
+
+classimDir = getClassimDir()
+runDir = os.path.join(classimDir,'run')
+storeDir = os.path.join(runDir,'store')
# Create soil executable
-createsoilexe = app_dir+'\\createsoilfiles.exe'
+createsoilexe = classimDir+'\\createsoilfiles.exe'
# maize model executables
-maizsimexe = app_dir+'\\2dmaizsim.exe'
+maizsimexe = classimDir+'\\2dmaizsim.exe'
# Potato model executable
-spudsimexe = app_dir+'\\2dspudsim.exe'
+spudsimexe = classimDir+'\\2dspudsim.exe'
# Soybean model executable
-glycimexe = app_dir+'\\2dglycim.exe'
+glycimexe = classimDir+'\\2dglycim.exe'
# Cotton model executable
-gossymexe = app_dir+'\\2dgossym.exe'
+gossymexe = classimDir+'\\2dgossym.exe'
# Flag to tell script if output files should be removed, the default is 1 so they are removed
remOutputFilesFlag = 0
-run_dir = os.path.join(app_dir,'run')
-if not os.path.exists(run_dir):
- os.makedirs(run_dir)
-
-runpath1= run_dir
-repository_dir = os.path.join(runpath1,'store')
-
## This should always be there
-if not os.path.exists(repository_dir):
- print('RotationTab Error: Missing repository_dir')
-
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
+if not os.path.exists(storeDir):
+ print('RotationTab Error: Missing storeDir')
class Rotation_Widget(QWidget):
# Add a signal
@@ -98,16 +57,16 @@ def __init__(self):
def init_ui(self):
self.setGeometry(QtCore.QRect(10,20,700,700))
- self.setFont(QtGui.QFont("Calibri",10))
+ self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
- self.importfaq("general")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.importfaq("rotation")
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.tab_summary = QTextEdit("To create your rotation you first need to select in this order: Site, \
@@ -694,7 +653,7 @@ def prepare_and_execute(self,simulation_name,rotationID,irow,theyear):
this will create input files, and execute both exe's
"""
self.simulation_name = str(simulation_name)
- field_path = os.path.join(runpath1,self.simulation_name)
+ field_path = os.path.join(runDir,self.simulation_name)
if not os.path.exists(field_path):
os.makedirs(field_path)
@@ -719,13 +678,11 @@ def prepare_and_execute(self,simulation_name,rotationID,irow,theyear):
lrainVar = self.tablebasket.cellWidget(irow,7).currentText()
lCO2Var = self.tablebasket.cellWidget(irow,8).currentText()
- #copy water.dat file from store to runpath1
- src_file = repository_dir+'\\Water.DAT'
+ src_file = storeDir+'\\Water.DAT'
dest_file = field_path+'\\Water.DAT'
copyFile(src_file,dest_file)
- #copy water.dat file from store to runpath1
- src_file= repository_dir+'\\WaterBound.DAT'
+ src_file= storeDir+'\\WaterBound.DAT'
dest_file= field_path+'\\WatMovParam.dat'
copyFile(src_file,dest_file)
@@ -737,11 +694,11 @@ def prepare_and_execute(self,simulation_name,rotationID,irow,theyear):
if cultivar != "fallow":
WriteCropVariety(lcrop,cultivar,field_name,field_path)
else:
- src_file= repository_dir+'\\fallow.var'
+ src_file= storeDir+'\\fallow.var'
dest_file= field_path+'\\fallow.var'
copyFile(src_file,dest_file)
WriteIrrigationFile(field_name,field_path)
- hourly_flag, edate = WriteWeather(lexperiment,ltreatmentname,lstationtype,lweather,field_name,field_path,ltempVar,lrainVar,lCO2Var)
+ hourly_flag, edate = WriteWeather(lexperiment,ltreatmentname,lstationtype,lweather,field_path,ltempVar,lrainVar,lCO2Var)
WriteSoluteFile(lsoilname,field_path)
WriteGasFile(field_path)
hourlyFlag = 1 if self.step_hourly.isChecked() else 0
diff --git a/Classim/TabbedDialog/SeasonalTab.py b/Classim/TabbedDialog/SeasonalTab.py
index b86e7fd..2fb283f 100644
--- a/Classim/TabbedDialog/SeasonalTab.py
+++ b/Classim/TabbedDialog/SeasonalTab.py
@@ -5,7 +5,8 @@
import sys
import re
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QTableWidget, QTableWidgetItem, QComboBox, QVBoxLayout, QPushButton, \
- QSpacerItem, QSizePolicy, QHeaderView, QRadioButton, QButtonGroup, QMenu, QCheckBox, QGridLayout, QGroupBox
+ QSpacerItem, QSizePolicy, QHeaderView, QRadioButton, QButtonGroup, QMenu, QCheckBox, QGridLayout, QGroupBox, \
+ QHeaderView
from PyQt5.QtCore import QFile, QTextStream, pyqtSignal, QCoreApplication
from CustomTool.custom1 import *
from CustomTool.UI import *
@@ -15,80 +16,35 @@
from TabbedDialog.tableWithSignalSlot import *
from subprocess import Popen
-global runpath1
-global app_dir
-global repository_dir
-
-#----------------------
-# at some point in the future we will have to figure out a solution of alternative documents folders
-#import winreg as wr
-#Registry = wr.ConnectRegistry(None, wr.HKEY_CURRENT_USER) # get a handle to the HKEY_CURRENT_USER branch in registry
-#RawKey = wr.OpenKey(Registry, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") # get a handle to the key we need
-#newPath=wr.QueryValueEx(RawKey,r"Personal") # retrieve a tuple with the information for the value of 'Personal'
-#gparent_dir=newPath[0] #0 is the directory name
-# this is gparent_dir
-#----------------
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-app_dir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(app_dir):
- os.makedirs(app_dir)
-
- print(os.listdir())
-
-global db
-db = app_dir+'\\crop.db'
+global classimDir
+global runDir
+global storeDir
+
+classimDir = getClassimDir()
+runDir = os.path.join(classimDir,'run')
+storeDir = os.path.join(runDir,'store')
# Create soil executable
-createsoilexe = app_dir+'\\createsoilfiles.exe'
+createsoilexe = classimDir+'\\createsoilfiles.exe'
# maize model executables
-maizsimexe = app_dir+'\\2dmaizsim.exe'
+maizsimexe = classimDir+'\\2dmaizsim.exe'
# Potato model executable
-spudsimexe = app_dir+'\\2dspudsim.exe'
+spudsimexe = classimDir+'\\2dspudsim.exe'
# Soybean model executable
-glycimexe = app_dir+'\\2dglycim.exe'
+glycimexe = classimDir+'\\2dglycim.exe'
# Cotton model executable
-gossymexe = app_dir+'\\2dgossym.exe'
+gossymexe = classimDir+'\\2dgossym.exe'
# Flag to tell script if output files should be removed, the default is 1 so they are removed
remOutputFilesFlag = 0
-run_dir = os.path.join(app_dir,'run')
-if not os.path.exists(run_dir):
- os.makedirs(run_dir)
-
-runpath1= run_dir
-repository_dir = os.path.join(runpath1,'store')
-
## This should always be there
-if not os.path.exists(repository_dir):
- print('RotationTab Error: Missing repository_dir')
-
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
- #print("text=", text)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
+if not os.path.exists(storeDir):
+ print('RotationTab Error: Missing storeDir')
class Seasonal_Widget(QWidget):
# Add a signal
@@ -101,16 +57,16 @@ def __init__(self):
def init_ui(self):
self.setGeometry(QtCore.QRect(10,20,700,700))
- self.setFont(QtGui.QFont("Calibri",10))
+ self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
- self.importfaq("general")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.importfaq("seasonal")
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.tab_summary = QTextEdit("Pick individual entries to create your simulation. You have the ability \
@@ -702,7 +658,7 @@ def prepare_and_execute(self,simulation_name,irow,theyear):
"""
this will create input files, and execute both exe's
"""
- field_path = os.path.join(runpath1,str(simulation_name[0]))
+ field_path = os.path.join(runDir,str(simulation_name[0]))
if not os.path.exists(field_path):
os.makedirs(field_path)
@@ -727,13 +683,13 @@ def prepare_and_execute(self,simulation_name,irow,theyear):
lrainVar = self.tablebasket.cellWidget(irow,11).currentText()
lCO2Var = self.tablebasket.cellWidget(irow,12).currentText()
- #copy water.dat file from store to runpath1
- src_file = repository_dir+'\\Water.DAT'
+ #copy water.dat file from store to runDir
+ src_file = storeDir+'\\Water.DAT'
dest_file = field_path+'\\Water.DAT'
copyFile(src_file,dest_file)
- #copy water.dat file from store to runpath1
- src_file= repository_dir+'\\WaterBound.DAT'
+ #copy water.dat file from store to runDir
+ src_file= storeDir+'\\WaterBound.DAT'
dest_file= field_path+'\\WatMovParam.dat'
copyFile(src_file,dest_file)
@@ -745,11 +701,11 @@ def prepare_and_execute(self,simulation_name,irow,theyear):
if cultivar != "fallow":
WriteCropVariety(lcrop,cultivar,field_name,field_path)
else:
- src_file= repository_dir+'\\fallow.var'
+ src_file= storeDir+'\\fallow.var'
dest_file= field_path+'\\fallow.var'
copyFile(src_file,dest_file)
WriteIrrigationFile(field_name,field_path)
- hourly_flag, edate = WriteWeather(lexperiment,ltreatmentname,lstationtype,lweather,field_name,field_path,ltempVar,lrainVar,lCO2Var)
+ hourly_flag, edate = WriteWeather(lexperiment,ltreatmentname,lstationtype,lweather,field_path,ltempVar,lrainVar,lCO2Var)
WriteSoluteFile(lsoilname,field_path)
WriteGasFile(field_path)
hourlyFlag = 1 if self.step_hourly.isChecked() else 0
diff --git a/Classim/TabbedDialog/SiteTab.py b/Classim/TabbedDialog/SiteTab.py
index 03083fe..bc22492 100644
--- a/Classim/TabbedDialog/SiteTab.py
+++ b/Classim/TabbedDialog/SiteTab.py
@@ -1,47 +1,13 @@
from asyncio.windows_events import NULL
import os
import sys
-from PyQt5.QtWidgets import QWidget, QLabel, QComboBox, QVBoxLayout, QPushButton, QSpacerItem, QSizePolicy, QCheckBox, QGridLayout
+from PyQt5.QtWidgets import QWidget, QLabel, QComboBox, QVBoxLayout, QPushButton, QSpacerItem, QSizePolicy, QCheckBox, QGridLayout, QHeaderView
from PyQt5.QtCore import pyqtSlot
from pyqtlet import L, MapWidget
from DatabaseSys.Databasesupport import *
from TabbedDialog.tableWithSignalSlot import *
from CustomTool.UI import *
-'''
-Contains 1 class and some GLOBALS. These GLOBALS can be refined and moved to centralized place, at the
-momemt lower priority.
-Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the
-tab classes. In future,we can centralize it. Lower priority.
-'''
-
-application_path = (
- os.path.dirname(sys.executable)
- if getattr(sys, "frozen", False)
- else os.path.dirname(__file__)
-)
-
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
-
class SiteWidget(QWidget):
def __init__(self):
super(SiteWidget,self).__init__()
@@ -52,13 +18,13 @@ def init_ui(self):
self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
- self.importfaq("field")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.importfaq("Site")
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.tab_summary = QTextEdit("")
diff --git a/Classim/TabbedDialog/SoilTab.py b/Classim/TabbedDialog/SoilTab.py
index 5184e19..a53a473 100644
--- a/Classim/TabbedDialog/SoilTab.py
+++ b/Classim/TabbedDialog/SoilTab.py
@@ -1,6 +1,6 @@
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QTableWidget, QTableWidgetItem, QComboBox, QVBoxLayout, \
- QPushButton, QSpacerItem, QSizePolicy, QMenu, QHeaderView, QCheckBox, QGridLayout
+ QPushButton, QSpacerItem, QSizePolicy, QMenu, QHeaderView, QCheckBox, QGridLayout, QHeaderView
from PyQt5.QtCore import pyqtSlot
from CustomTool.custom1 import *
from CustomTool.UI import *
@@ -14,11 +14,8 @@
import requests
'''
-Contains 2 classes.
-1). Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the
- tab classes. In future,we can centralize it. Lower priority.
-
-2). Class Soil_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget.
+Contains 1 class
+1). Class Soil_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget.
It handles all the features of SOIL Tab on the interface.
It has signal slot mechanism. It does interact with the DatabaseSys\Databasesupport.py for all the
databases related task.
@@ -26,26 +23,6 @@
Refer baseline classes at http://pyqt.sourceforge.net/Docs/PyQt5/QtWidgets.html#PyQt5-QtWidgets
'''
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
class Soil_Widget(QWidget):
def __init__(self):
@@ -55,16 +32,16 @@ def __init__(self):
def init_ui(self):
self.setGeometry(QtCore.QRect(10,20,700,700))
- self.setFont(QtGui.QFont("Calibri",10))
+ self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
- self.importfaq("soil")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.importfaq("Soil")
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.tab_summary = QTextEdit()
diff --git a/Classim/TabbedDialog/WeatherTab.py b/Classim/TabbedDialog/WeatherTab.py
index fb4bb32..4c05989 100644
--- a/Classim/TabbedDialog/WeatherTab.py
+++ b/Classim/TabbedDialog/WeatherTab.py
@@ -5,7 +5,7 @@
from urllib.error import URLError
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QWidget, QLabel, QComboBox, QVBoxLayout, QPushButton, QSizePolicy, \
- QMessageBox, QFileDialog, QScrollArea, QCheckBox, QGridLayout
+ QMessageBox, QFileDialog, QScrollArea, QCheckBox, QGridLayout, QHeaderView
from PyQt5.QtCore import pyqtSlot
from CustomTool.custom1 import *
from CustomTool.UI import *
@@ -16,47 +16,16 @@
from datetime import datetime, timedelta
from dateutil import parser
-gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-dbDir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(dbDir):
- os.makedirs(dbDir)
-
-global db
-db = dbDir+'\\crop.db'
-
ssl._create_default_https_context = ssl._create_unverified_context
'''
-Contains 2 classes.
-1). Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the tab classes. In
- future,we can centralize it. Lower priority.
-2). Class Weather_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget.
+Contains 1 class.
+1). Class Weather_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget.
It handles all the features of Weather Tab on the interface. It has signal slot mechanism. It does interact with the
DatabaseSys\Databasesupport.py for all the databases related task.
Pretty generic and self explanotory methods.
Refer baseline classes at http://pyqt.sourceforge.net/Docs/PyQt5/QtWidgets.html#PyQt5-QtWidgets
'''
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
class Weather_Widget(QWidget):
def __init__(self):
@@ -69,13 +38,13 @@ def init_ui(self):
self.setFont(QtGui.QFont("Calibri",10))
self.faqtree = QtWidgets.QTreeWidget(self)
self.faqtree.setHeaderLabel('FAQ')
- self.faqtree.setGeometry(500,200, 400, 300)
+ self.faqtree.setGeometry(500,200, 400, 400)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
self.faqtree.setFont(QtGui.QFont("Calibri",10))
self.importfaq("weather")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.faqtree.setVisible(False)
self.tab_summary = QTextEdit()
@@ -299,7 +268,7 @@ def showweatherdetailscombo(self,value):
def getWeatherSummary(stationtype):
# getting weather data from sqlite
- conn, c = openDB(db)
+ conn, c = openDB('crop.db')
if c:
weather_query = "select weather_id, date, hour, srad, wind, rh, rain, tmax, tmin, temperature from weather_data where stationtype=?"
df_weatherdata = pd.read_sql(weather_query,conn,params=[stationtype])
@@ -430,7 +399,7 @@ def upload_csv(self):
data['jday'] = pd.to_datetime(data['date']).dt.strftime('%j')
dateList = pd.to_datetime(data['date'])
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
# Check if data already exists in the database for stationType for this date range
minDate = min(dateList)
maxDate = max(dateList)
@@ -526,7 +495,7 @@ def downloadWeatherData(self):
data['rh'] = data['rh'] * 100
msgBox.close()
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
# Check if data already exists in the database for stationType for this date range
dateList = data['date']
diff --git a/Classim/TabbedDialog/WelcomeTab.py b/Classim/TabbedDialog/WelcomeTab.py
index 34ce992..b56d7a1 100644
--- a/Classim/TabbedDialog/WelcomeTab.py
+++ b/Classim/TabbedDialog/WelcomeTab.py
@@ -1,5 +1,5 @@
import os
-from PyQt5.QtWidgets import QTreeWidgetItem, QTabWidget, QLabel, QHBoxLayout, QVBoxLayout
+from PyQt5.QtWidgets import QTreeWidgetItem, QTabWidget, QLabel, QHBoxLayout, QVBoxLayout, QHeaderView
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import pyqtSignal
from CustomTool.custom1 import *
@@ -10,32 +10,11 @@
from collections import deque
from pathlib import Path
-global runpath1
-global app_dir
-global repository_dir
-
gusername = os.environ['username'] #windows. What about linux
-gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
-app_dir = os.path.join(gparent_dir,'classim')
-if not os.path.exists(app_dir):
- os.makedirs(app_dir)
-
-run_dir = os.path.join(app_dir,'run')
-if not os.path.exists(run_dir):
- os.makedirs(run_dir)
-
-runpath1 = run_dir
-repository_dir = os.path.join(runpath1,'store')
-
-## This should always be there
-if not os.path.exists(repository_dir):
- print('RotationTab Error: Missing repository_dir')
'''
-Contains 2 classes.
-1). Class ItemWordWrap is to assist the text wrap features. You will find this class at the top of all the tab classes. In future,we can centralize it. Lower priority.
-
-2). Class Welcome_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget. It is acting like a index page of a book. It handles all the features of WELCOME Tab on the interface.
+Contains 1 class
+1). Class Welcome_Widget is derived from Qwidget. It is initialed and called by Tabs.py -> class Tabs_Widget. It is acting like a index page of a book. It handles all the features of WELCOME Tab on the interface.
It has signal slot mechanism. It does interact with the DatabaseSys\Databasesupport.py for all the databases related task.
Pretty generic and self explanotory methods.
Refer baseline classes at http://pyqt.sourceforge.net/Docs/PyQt5/QtWidgets.html#PyQt5-QtWidgets
@@ -44,28 +23,6 @@
Check out the logic for images/icons.
'''
-#this is widget of type 1. It would be added to as a tab
-class ItemWordWrap(QtWidgets.QStyledItemDelegate):
- def __init__(self, parent=None):
- QtWidgets.QStyledItemDelegate.__init__(self, parent)
- self.parent = parent
-
-
- def paint(self, painter, option, index):
- text = index.model().data(index)
-
- document = QtGui.QTextDocument()
- document.setHtml(text)
-
- document.setTextWidth(option.rect.width()) #keeps text from spilling over into adjacent rect
- index.model().setData(index, option.rect.width(), QtCore.Qt.UserRole+1)
- painter.setPen(QtGui.QPen(Qt.blue))
- painter.save()
- painter.translate(option.rect.x(), option.rect.y())
- document.drawContents(painter) #draw the document with the painter
- painter.restore()
-
-
class Welcome_Widget(QTabWidget):
# Add a signal to notify parent tab that user has selected following tabindex#
welcomesig = pyqtSignal(int)
@@ -83,21 +40,22 @@ def init_ui(self):
self.faqtree.setGeometry(500,200, 300, 500)
self.faqtree.setUniformRowHeights(False)
self.faqtree.setWordWrap(True)
- self.faqtree.setFont(QtGui.QFont("Calibri",10))
+ self.faqtree.setFont(QtGui.QFont("Calibri",10))
+ self.faqtree.header().setStretchLastSection(False)
+ self.faqtree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
self.importfaq("welcome")
- self.faqtree.header().resizeSection(1,200)
- self.faqtree.setItemDelegate(ItemWordWrap(self.faqtree))
+
self.mainlayout1 = QHBoxLayout()
self.welcomeglayout1 = QVBoxLayout()
# Read crop.db user version
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
query = "pragma user_version"
cropDB = pd.read_sql_query(query,conn)
# Read cropOutput.db user version
- conn, c = openDB(dbDir + '\\cropOutput.db')
+ conn, c = openDB('cropOutput.db')
query = "pragma user_version"
cropOutDB = pd.read_sql_query(query,conn)
diff --git a/Classim/TabbedDialog/tableWithSignalSlot.py b/Classim/TabbedDialog/tableWithSignalSlot.py
index 1d1387b..ee7a034 100644
--- a/Classim/TabbedDialog/tableWithSignalSlot.py
+++ b/Classim/TabbedDialog/tableWithSignalSlot.py
@@ -335,7 +335,7 @@ def showNewTreatmentDialog(self,value,strval1,strval2):
def getTreatmentSummary(ename,cname,tname):
- conn, c = openDB(dbDir + '\\crop.db')
+ conn, c = openDB('crop.db')
if c:
# Get treatment id
tid = getTreatmentID(tname,ename,cname)
diff --git a/Classim/classim_rb.pyproj b/Classim/classim_rb.pyproj
index d54d6f7..c026f0c 100644
--- a/Classim/classim_rb.pyproj
+++ b/Classim/classim_rb.pyproj
@@ -43,6 +43,7 @@
+
Code