modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

add reference parameters to get_node_coordinates() #58

Closed flydream0428 closed 8 years ago

flydream0428 commented 9 years ago

Hi Guys, at this moment, the get_node_coordinates() doesn't allow you to specify xul and yul or some other reference parameters like these. I suggest to add xul and yul to this function to let it return the true coordinates. Also, it will be useful to have another function to let you find the coordinates for a number of nodes rather than the whole model cells. I can help to implement this task if you think it's a good idea.

jtwhite79 commented 9 years ago

I believe ModflowDis.get_node_coordinates() is a method that is used by the modflow2netcdf module - that module expects the coordinates in model space (e.g not offset and/or rotated). If you need access to offset and rotated model grid information, please use the SpatialReference class, which I think it is currently only available in the develop branch.

flydream0428 commented 9 years ago

Hi jtwhilte, thanks for your reply. I just checked the SpatialReference class (both the one in the branch in developing and the master). Although xul, yul and rotation can be given during the class initialization. The xcenter and ycenter properties do not take xul, yul and rotation into account. It's not a big deal, because we can do the math once we have the model coordinates. However, I guess that most people will expect to see site coordinates once they set up the offset and rotation parameters.

jtwhite79 commented 9 years ago

that's true - those are currently only used internally in SpatialReference to build the grid attributes. I'll probably end up making those private to discourage their use.

On Wed, Oct 21, 2015 at 7:34 PM, flydream0428 notifications@github.com wrote:

Hi jtwhilte, thanks for your reply. I just checked the SpatialReference class (both the one in the branch in developing and the master). Although xul, yul and rotation can be given during the class initialization. The xcenter and ycenter properties do not take xul, yul and rotation into account. It's not a big deal, because we can do the math once we have the model coordinates. However, I guess that most people will expect to see site coordinates once they set up the offset and rotation parameters.

— Reply to this email directly or view it on GitHub https://github.com/modflowpy/flopy/issues/58#issuecomment-150063346.

flydream0428 commented 9 years ago

The other choice is to add a couple of other functions/properties, such as xcenter_site and ycenter_site. The current ones then can be reserved to build the grid attributes. Then end users will then be expected to mainly use the site coordinates. This will be more useful when you begin to overlap modelling result with shape files.

aleaf commented 9 years ago

Jeremy, what do you think about providing access to the SpatialReference functionality through the DIS class? So that if you provided offset and rotation to DIS, you could interrogate DIS to get geographic information for any cell. And then with the to_shapefile() method, one could simply supply an argument to have the shapefile produced in "site coordinates." I know that I would find this useful and I suspect many others would as well. I would be happy to work on this if you don't have plans to implement it (or something similar) in the near future.

jtwhite79 commented 9 years ago

So currently, the SpatialReference object is attached to ModflowDis - you can pass the ModflowDis constructor xul, yul, and rotation and it will instantiate a SpatialReference for you. It is accessible as: model.dis.sr. The to_shapefile() methods of model, package and util objects already use this information - that is why resulting shapefiles are offset and rotated, as are the plots from the .plot() methods. Is this what you are asking about? I don't think it makes sense to have a shapefile that doesn't respect offset and rotation...right?

I'm planning to move all of the shapefile stuff into the export module soon. In export.utils, there are set of helper functions that use the passed filename extension to decide what to do: .nc for netcdf is currently all that is there. But I think it would be nice to have the shapefile stuff there too - feel free to make this happen!

aleaf commented 9 years ago

Ok, good to know! I hadn't realized that.

hwreeves-USGS commented 8 years ago

Is the shapefile export for a grid in the export module? I was going to try and put that together, but it looks like you are already doing that. I just need a simple shapefile of the grid with row, column attributes.

langevin-usgs commented 8 years ago

Howard, take a look at this notebook (https://github.com/modflowpy/flopy/blob/develop/examples/Notebooks/flopy3_export.ipynb) for an example of exporting to a shapefile.

hwreeves-USGS commented 8 years ago

thanks Chris, that is in the develop branch -- is there a way to have both develop and master versions of flopy installed? If I clone the repo, can I make flopy directly on my machine (switch between master and develop) versions? sorry for such basic GitHub questions, but I haven't dealt much with it

langevin-usgs commented 8 years ago

Howard, I install flopy from a local source tree (http://python-packaging-user-guide.readthedocs.org/en/latest/installing/#installing-from-a-local-src-tree). I then use the sourcetree program to activate which version I want to use. Normally this is always the develop branch in my case.

So the workflow is to clone flopy. Install it from a local source tree so that Python sees it where it is located. I then checkout the develop branch.