GROUNDWATER MODELING - Home



When you start working with python, you will have (at least) two options. You can use Spyder, which is a simpler interface, but with some powerful capabilities. Or, you can use Jupyter Notebooks, which is a cleaner interface that helps you to organize your code, but it can be limiting in some cases. Chloe’s examples are written in Notebooks. The following instructions will help you to get up and running with either method!Anaconda and package Installation.To run either Notebooks or Spyder, you should first download Anaconda - Python 3.7 version (). Make sure you download the correct version for your laptop (windows/macOS/Linux).127635098806000After installing Anaconda. You will want to establish an environment for the class. From the conda promplt (like the black screen shown below) type: conda create --name hwr582. This makes a ‘space’ within your anaconda working environment wherein you can change things specifically for the course without altering your general environment. Then activate the environment by typing: conda activate hwr582. This is like changing the directory to your class working directory.Within the new environment, you will need to install numpy, matplotlib, jupyter, and flopy. These are packages (sets of instructions or codes) that have been written and that you can use once you install them. In this case, you should use these codes to install them:conda install -c conda-forge flopyconda install -c conda-forge numpyconda install -c conda-forge matplotlibconda install jupyter*If you are installing in a new environment, you shouldn’t have any previous versions to overwrite. Also, you should do this installation FIRST and then look at Chloe’s notes for some specific requirements to install versions of these packages that are needed for flopy to run properly.217236117438600020610000When the Anaconda Prompt asks you if you want to update the package, the answer is yes (“y”).866775197167600Finally, you must restart your computer. At this point, you have your Anaconda environment set up. Just remember to activate the hwr582 environment when you start working on a class project.SpyderAfter installing Anaconda, you will be able to use Spyder. Spyder is an interface written for Python. It looks a lot like MATLAB, if you have used that software. First, you need to download the zip file from the class’s web site (). The name of the file is “ghw1.zip”.400050188023500Your code is going to call MODFLOW, run it, and extract the results. So, you need to know where the MODFLOW code resides. The best thing to do is to download MODFLOW-2005 from the USGS ().790575149542500Then you need to find where it has downloaded, open the MODFLOW-2005 folder, and find the MODFLOW program files.161925063627000Copy and paste those programs in the GW1 folder. Here is is shown in the Downloads folder. But, you may want to put this in a folder associated with python, or the class … somewhere that it is less likely to get deleted by mistake!1619250113093500You are ready to use Spyder! Probably the best way to do this is to first change directories (cd) to the folder that has (or will have) your code. For example, if you open Anaconda and it is in C:\, the you would want to type cd Users\Administrator\Downloads\GHW1. Then when you type spyder at anaconda the prompt it will be easy to open your code or save it to this directory.781050121920000You can download the GMW1 folder with the MODFLOW-2005 files from: . To review: download the code, install Anaconda, open Spyder, open the file that you want to run, and run the code using the green arrow icon. When it finishes running, your results will display on the right side – in the iPython console.3133725184721500JupyterFirst, you need to download the “ghw1.ipynb” file from the class’s web site (). You may have noticed that Spyder (.py) and Jupyter (.ipynb) use different type of file. If you run a Jupyter file, you can save it as a Python script (.py) and use it in Spyder, but you must have all the necessary files on the folder to run the code. But, in general, it is best to choose spyder or notebooks and stick with it.Assuming that you have done the first five steps above, you can launch the Anaconda Prompt, activate your hwr582 environment, and write this command: jupyter notebook. (Again, it will be easier if you first change directory to your working directory, but you can also navigate there from within jupyter notebooks.95249921336000Your web browser will open a new tab. This lists the files in the directory from which you launched Anaconda. So, you may need to navigate to the correct directory.Once you find your code, you can click it to open in Notebooks. 533400132397500The best way to run the code is under Kernel – restart and run all. This ensures that you are ‘starting fresh’ with no relict variables. The results are shown beneath each ‘cell’ in the code. You can also run one cell by putting the cursor in the cell and hitting shift-enter. (Nice feature, but can end up failing if you haven’t run the earlier cells yet!) You should get the same results as Spyder. 1209675185673900Instructions provided by Hector Venegas Quinones, 2019 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download