Has anyone tried to add proper to a conda environment? The setup.py didn't work as a pip-install on my machine. I did run the setup.py while in an environment, but it wasn't added automatically.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the above suggestion. I was able to get Proper installed into
a conda environment.
On a different note, I have a code suggestion for you regarding Proper.
This is something I have run into trying to get proper to run prescriptions
that I have defined elsewhere. For various reasons, I am running the code
from a remote directory relative to where the prescriptions are stored.
When I try to then run proper, I need to specify the relative location of
the perscription to the prop_run.py code. However, it states in the intro
of the code:
def prop_run(routine_name, lambda0, gridsize, **kwargs):
"""Execute a prescription.
Parameters----------
routine_name : str
Filename (excluding extension) of the python routine containing the
prescription.
So the filename cannot include the extension. I believe it says that
because in lines 129-135 you use a function to import the module, and then
get the specific prescription from the module using python's internal
getattr:
try:
module = importlib.import_module(routine_name)
except ImportError:
raise ImportError("Unable to run %s prescription. Stopping." %routine_name)
func = getattr(module, routine_name)
routine_name is one of the arguments passed into prop_run as a string.
importlib.import_module() then imports the module and stores it as a
variable, module. the importlib statement can easily handle relative path
names. However, the next line where func = getattr(module, routine_name)
will break if routine_name is a relative path string.
You can fix this with the following lines of code:
f1 = os.path.basename(module.file)
f2 = os.path.splitext(f1)[0]
func = getattr(module, f2)
This will give you the attrube with the name stored in f2 of the module and
save it as func. This will work regardless of what is specified in
routine_name since the .file global attribute gives the full path name
of whatever was returned by the importlib statement.
I hope this is helpful and relevant information. You could probably cram
that all into a single line if you wanted, but at the expense of
readability. Please consider updating the prop_run.py file.
Has anyone tried to add proper to a conda environment? The setup.py didn't
work as a pip-install on my machine. I did run the setup.py while in an
environment, but it wasn't added automatically.
--
Kristina K. Davis, PhD.
Astronomy & Astrophysics Postdoctoral Fellow
National Science Foundation
University of California, Santa Barbara
k_davis@physics.ucsb.edu
kristinadavis.weebly.com
Sorry for the delay - I had to get my Python person to figure this out. Here's what he said. Let me know if this works.
Yes, I was able to create a conda environment for python 2.7 PROPER and run examples. Few points to note:
Conda does not work seamlessly with pip installer. One has to install supporting packages using conda (if they are available) rather than pip and only install packages using pip that are not available in conda.
Pyfits is deprecated and FITS write/read module in astropy should be used
Latest version of astropy (version 3.0) does not support Python 2.7. One has to explicitly use astropy version 2.0 in Python 2.7
Steps to setup conda environment for Python 2.7:
1. (optional) Update conda
> conda update -n base conda
Create a new conda environment for PROPER
> conda create --name PROPER2.7
The conda environment could be named anything the user desires.
Install required and optional packages in the conda environment (these version worked for me)
Has anyone tried to add proper to a conda environment? The setup.py didn't work as a pip-install on my machine. I did run the setup.py while in an environment, but it wasn't added automatically.
Thank you for the above suggestion. I was able to get Proper installed into
a conda environment.
On a different note, I have a code suggestion for you regarding Proper.
This is something I have run into trying to get proper to run prescriptions
that I have defined elsewhere. For various reasons, I am running the code
from a remote directory relative to where the prescriptions are stored.
When I try to then run proper, I need to specify the relative location of
the perscription to the prop_run.py code. However, it states in the intro
of the code:
def prop_run(routine_name, lambda0, gridsize, **kwargs):
"""Execute a prescription.
So the filename cannot include the extension. I believe it says that
because in lines 129-135 you use a function to import the module, and then
get the specific prescription from the module using python's internal
getattr:
try:
module = importlib.import_module(routine_name)
except ImportError:
raise ImportError("Unable to run %s prescription. Stopping." %routine_name)
func = getattr(module, routine_name)
routine_name is one of the arguments passed into prop_run as a string.
importlib.import_module() then imports the module and stores it as a
variable, module. the importlib statement can easily handle relative path
names. However, the next line where func = getattr(module, routine_name)
will break if routine_name is a relative path string.
You can fix this with the following lines of code:
f1 = os.path.basename(module.file)
f2 = os.path.splitext(f1)[0]
func = getattr(module, f2)
This will give you the attrube with the name stored in f2 of the module and
save it as func. This will work regardless of what is specified in
routine_name since the .file global attribute gives the full path name
of whatever was returned by the importlib statement.
I hope this is helpful and relevant information. You could probably cram
that all into a single line if you wanted, but at the expense of
readability. Please consider updating the prop_run.py file.
Thank you,
Kristina
On Wed, Jan 23, 2019 at 11:07 AM KDavis kyle-astro@users.sourceforge.net
wrote:
--
Kristina K. Davis, PhD.
Astronomy & Astrophysics Postdoctoral Fellow
National Science Foundation
University of California, Santa Barbara
k_davis@physics.ucsb.edu
kristinadavis.weebly.com
Sorry for the delay - I had to get my Python person to figure this out. Here's what he said. Let me know if this works.
Yes, I was able to create a conda environment for python 2.7 PROPER and run examples. Few points to note:
Steps to setup conda environment for Python 2.7:
1. (optional) Update conda
> conda update -n base conda
> conda create --name PROPER2.7
The conda environment could be named anything the user desires.
ipython and matplotlib are optional.
Remove any install PROPER packages from user's local directory ($HOME/.local)
Activate PROPER conda environment
Install PyPROPER package inside conda environment
Once successfully installed, try the following in python or ipython sheel to see if proper is installed correctly