Skip to content

Commit

Permalink
Merge pull request #17 from Stepania/TestingSystem
Browse files Browse the repository at this point in the history
more spaces
  • Loading branch information
HamishBrownPFR authored Nov 16, 2023
2 parents 98f8aa4 + bd8570b commit 2c8d967
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 78 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ubuntodotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ name: .NET

on: pull_request_target


jobs:
build:

Expand Down Expand Up @@ -90,5 +89,9 @@ jobs:

- name: Override page_url
id: change-page-url
run: echo "new_page_url=${{ steps.deployment.outputs.page_url }}index.html" >> $GITHUB_OUTPUT
run: echo "new_page_url=${{ steps.deployment.outputs.page_url }}index.html" >> $GITHUB_OUTPUT

- name: ls
run: ls -a


119 changes: 54 additions & 65 deletions Untitled1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 7,
"id": "80f8560c",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -74,68 +74,6 @@
"row_num=len(tests)\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "450e209b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(tests)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3a6f38d5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['8Oat', '8Peas', '8Wheat'], dtype='object')"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tests"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "561bcb7b",
"metadata": {},
"outputs": [],
"source": [
"dt.datetime.date(AllData[t].dropna().index.min())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "932efb34",
"metadata": {},
"outputs": [],
"source": [
"dt.datetime.date(AllData[t].dropna().index.max())"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -158,7 +96,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 11,
"id": "ca1e0e45",
"metadata": {},
"outputs": [],
Expand All @@ -180,7 +118,58 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 24,
"id": "d8324dac",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "'Timestamp' object cannot be interpreted as an integer",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[24], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m dt\u001b[38;5;241m.\u001b[39mdatetime(observed_data_currentTest\u001b[38;5;241m.\u001b[39mindex[\u001b[38;5;241m0\u001b[39m])\n",
"\u001b[1;31mTypeError\u001b[0m: 'Timestamp' object cannot be interpreted as an integer"
]
}
],
"source": [
"dt.datetime(observed_data_currentTest.index[0])"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "ff88db9b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"DatetimeIndex(['2020-08-28', '2020-10-22', '2020-11-20', '2020-12-18',\n",
" '2021-01-21', '2021-02-19', '2021-03-15', '2021-04-12',\n",
" '2021-05-13', '2021-06-16', '2021-07-12', '2021-08-12',\n",
" '2021-09-15', '2021-10-20', '2021-11-17', '2021-12-20',\n",
" '2022-01-26', '2022-03-03', '2022-04-05', '2022-05-12',\n",
" '2022-06-08', '2022-08-25', '2022-09-29', '2022-11-03',\n",
" '2022-12-05', '2023-01-25', '2023-03-02', '2023-04-04',\n",
" '2023-05-17', '2023-06-27', '2023-08-08'],\n",
" dtype='datetime64[ns]', name='Date', freq=None)"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"observed_data_currentTest.index"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "b2b95dab",
"metadata": {},
"outputs": [
Expand Down
6 changes: 5 additions & 1 deletion modelCsharp/TestModel/TestModel/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,18 @@ public static void RunTests(Dictionary<string, object> _configDict)
string folderName = "OutputFiles";

string fertiliserFolder = "NitrogenApplied";

if (!Directory.Exists(folderName) && !Directory.Exists(fertiliserFolder))
{
System.IO.Directory.CreateDirectory("OutputFiles");
System.IO.Directory.CreateDirectory("NitrogenApplied");

}

// on local machine
//DataFrame.SaveCsv(newDataframe, dir + "\\OutputFiles\\" + test + ".csv");

//for an action
DataFrame.SaveCsv(newDataframe, test + ".csv");

}
Expand Down
50 changes: 40 additions & 10 deletions modelCsharp/TestModel/testGraph/testGraph/testGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime as dt
import aspose.words as aw
import shutil
import pdb

path = os.getcwd()

Expand All @@ -13,8 +14,14 @@
#run this code for an action
observed_path = "TestModel/Observed/observed.csv"

# fertiliser input
#observed_path = os.path.join(path, "../../../../TestModel/TestModel/FertiliserData.csv")

observed_data = pd.read_csv(observed_path,index_col=0)

# fertiliser input
#observed_data = pd.read_csv(observed_path,index_col=[0,1])

observed_data.sort_index(axis=0,inplace=True)

tests = []
Expand All @@ -27,22 +34,26 @@
#tests.append(file)
#test_name.append(os.path.splitext(file)[0])

for file in os.listdir(path):
#uncomment it for an Action
#for file in os.listdir(path):

if file.endswith('.csv'):
tests.append(file)
test_name.append(os.path.splitext(file)[0])

#if file.endswith('.csv'):
#tests.append(file)
#test_name.append(os.path.splitext(file)[0])

Alltests =[]
for t in tests[:]:

testframe = pd.read_csv(t,index_col=0,dayfirst=True,date_format='%d/%m/%Y %H:%M:%S %p')

#uncomment it for an Action
testframe = pd.read_csv(t,index_col=0,dayfirst=True,date_format='%d/%m/%Y %H:%M:%S %p')

#testframe = pd.read_csv(path + "\\OutputFiles\\"+t,index_col=0,dayfirst=True,date_format='%d/%m/%Y %H:%M:%S %p')

Alltests.append(testframe)

AllData = pd.concat(Alltests,axis=1,keys=test_name)

#uncomment it for a observed.csv
observed_data.index=pd.to_datetime(observed_data.index,format="%d/%m/%Y %H:%M")

observed_test = observed_data.columns.get_level_values(0).drop_duplicates()
Expand All @@ -58,9 +69,14 @@

def makeplot(Data,color):
plt.plot(Data,color=color)


# uncomment it for observed,csv
def make_observed(observed):
plt.plot(observed.index,observed.loc[:,'Nitrogen'],'*',color='g')
plt.plot(observed.index,observed.loc[:,'Nitrogen'],'*',color='g')

# fertiliser input
#def make_observed(observed):
#plt.plot(observed.index,observed.loc[:,'0-30cm'],'*',color='g')

Graph = plt.figure(figsize=(10,10))
pos = 1
Expand All @@ -69,7 +85,18 @@ def make_observed(observed):
for t in tests:
start = dt.datetime.date(AllData[t].dropna().index.min())
end = dt.datetime.date(AllData[t].dropna().index.max())

datefilter = []
# fertiliser input
#observed_data_currentTest = observed_data.loc[int(t[0]),:]
#for d in observed_data_currentTest.index:
#datata=dt.datetime.strptime(d,'%Y-%m-%d')
#ret = False
#if ((datata>= pd.Timestamp(start)) and (datata<=pd.Timestamp(end))):
#ret = True
#datefilter.append(ret)

#uncomment it for observed.csv
for d in observed_data.index:
ret = False
if ((d >= pd.Timestamp(start)) and (d<=pd.Timestamp(end))):
Expand All @@ -85,6 +112,8 @@ def make_observed(observed):
makeplot(Data,color)
make_observed(observed_data[datefilter])
Graph.tight_layout(pad=1.5)
Graph.suptitle('DRAFT VERSION',fontsize = 32, color = "r")

pos+=1

Graph.add_subplot(row_num,2,pos)
Expand All @@ -94,7 +123,8 @@ def make_observed(observed):
makeplot(Data,color)
make_observed(observed_data[datefilter])
pos+=1



plt.savefig('testplot.png')

doc = aw.Document()
Expand Down
Binary file removed testplot.png
Binary file not shown.

0 comments on commit 2c8d967

Please sign in to comment.