[Errno 2} No such file or directory
Verfasst: Donnerstag 11. Oktober 2018, 11:09
Hallo alle,
ich bin neu hier im Forum.
Ich wollte mit Python ein Grundwasssermodell mit dem package flopy erstellen.
Als Benutzeroberfläche verwende ich Pycharm.
Mein Ziel ist es, dass Python nach der Berechnung mir die Ergebnisse als eine Grafik ausgibt.
Mein Code sieht wie folgt aus:
import flopy
import numpy as np
# Assign name and create modflow model obj
filename = 'tutorial1'
mf = flopy.modflow.Modflow(filename, exe_name='mf2005')
# Model domain and grid definition
Lx = 1000
Ly = 1000
ztop = 0
zbot = -50
nlay = 1
nrow = 10
ncol = 10
delr = Lx/ncol
delc = Ly/nrow
delv = (ztop-zbot)/nlay
botm = np.linspace(ztop, zbot, nlay+1)
# create the discretization object
dis = flopy.modflow.ModflowDis(mf, nlay, nrow, ncol, delr=delr, delc=delc, top=ztop, botm=botm[1:])
# Variables fpr BAS Package
ibound = np.ones((nlay, nrow, ncol), dtype=np.int32)
ibound[:, :, :0] = -1
ibound[:, :, :-1] = -1
strt = np.ones((nlay, nrow, ncol), dtype=np.float32)
strt[:, :, 0] = 10
strt[:, :, -1] = 0
bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)
# Layer-Property
lpf = flopy.modflow.ModflowLpf(mf, hk=10., vka=10., ipakcb=53)
# output
spd = {(0, 0): ['print head', 'print budget', 'save head', 'save budget']}
oc = flopy.modflow.ModflowOc(mf, stress_period_data=spd, compact=True)
# Gradient
pcg = flopy.modflow.ModflowPcg(mf)
mf.write_input()
import matplotlib.pyplot as plt
import flopy.utils.binaryfile as bf
from tutorial1 import filename
plt.subplot(1,1,1,aspect='equal')
hds = bf.HeadFile(filename+'.hds')
head = hds.get_data(totim=1.0)
levels = np.arange(1,10,1)
extent = (delr/2., Lx - delr/2., Ly - delc/2., delc/2.)
plt.contour(head[0, :, :], levels=levels, extent=extent)
plt.savefig('tutorial1a.png')
Leider erhalte ich immer die Fehlernachricht:
Traceback (most recent call last):
File "C:/Users/Johannes/PycharmProjects/getting_started/heads.py", line 7, in <module>
hds = bf.HeadFile(filename+'.hds')
File "C:\Users\Johannes\PycharmProjects\getting_started\venv\lib\site-packages\flopy\utils\binaryfile.py", line 436, in __init__
precision = get_headfile_precision(filename)
File "C:\Users\Johannes\PycharmProjects\getting_started\venv\lib\site-packages\flopy\utils\binaryfile.py", line 202, in get_headfile_precision
f = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'tutorial1.hds'
Der Code stammt aus einem Beispiel und wurde als einfaches Einstiegstutorial beschrieben.
Ich bin für jeden Ratschlag offen.
Danke für eure Hilfe.
ich bin neu hier im Forum.
Ich wollte mit Python ein Grundwasssermodell mit dem package flopy erstellen.
Als Benutzeroberfläche verwende ich Pycharm.
Mein Ziel ist es, dass Python nach der Berechnung mir die Ergebnisse als eine Grafik ausgibt.
Mein Code sieht wie folgt aus:
import flopy
import numpy as np
# Assign name and create modflow model obj
filename = 'tutorial1'
mf = flopy.modflow.Modflow(filename, exe_name='mf2005')
# Model domain and grid definition
Lx = 1000
Ly = 1000
ztop = 0
zbot = -50
nlay = 1
nrow = 10
ncol = 10
delr = Lx/ncol
delc = Ly/nrow
delv = (ztop-zbot)/nlay
botm = np.linspace(ztop, zbot, nlay+1)
# create the discretization object
dis = flopy.modflow.ModflowDis(mf, nlay, nrow, ncol, delr=delr, delc=delc, top=ztop, botm=botm[1:])
# Variables fpr BAS Package
ibound = np.ones((nlay, nrow, ncol), dtype=np.int32)
ibound[:, :, :0] = -1
ibound[:, :, :-1] = -1
strt = np.ones((nlay, nrow, ncol), dtype=np.float32)
strt[:, :, 0] = 10
strt[:, :, -1] = 0
bas = flopy.modflow.ModflowBas(mf, ibound=ibound, strt=strt)
# Layer-Property
lpf = flopy.modflow.ModflowLpf(mf, hk=10., vka=10., ipakcb=53)
# output
spd = {(0, 0): ['print head', 'print budget', 'save head', 'save budget']}
oc = flopy.modflow.ModflowOc(mf, stress_period_data=spd, compact=True)
# Gradient
pcg = flopy.modflow.ModflowPcg(mf)
mf.write_input()
import matplotlib.pyplot as plt
import flopy.utils.binaryfile as bf
from tutorial1 import filename
plt.subplot(1,1,1,aspect='equal')
hds = bf.HeadFile(filename+'.hds')
head = hds.get_data(totim=1.0)
levels = np.arange(1,10,1)
extent = (delr/2., Lx - delr/2., Ly - delc/2., delc/2.)
plt.contour(head[0, :, :], levels=levels, extent=extent)
plt.savefig('tutorial1a.png')
Leider erhalte ich immer die Fehlernachricht:
Traceback (most recent call last):
File "C:/Users/Johannes/PycharmProjects/getting_started/heads.py", line 7, in <module>
hds = bf.HeadFile(filename+'.hds')
File "C:\Users\Johannes\PycharmProjects\getting_started\venv\lib\site-packages\flopy\utils\binaryfile.py", line 436, in __init__
precision = get_headfile_precision(filename)
File "C:\Users\Johannes\PycharmProjects\getting_started\venv\lib\site-packages\flopy\utils\binaryfile.py", line 202, in get_headfile_precision
f = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'tutorial1.hds'
Der Code stammt aus einem Beispiel und wurde als einfaches Einstiegstutorial beschrieben.
Ich bin für jeden Ratschlag offen.
Danke für eure Hilfe.