Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anaconda Installation Instructions and Bug Fix #55

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions Install-conda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
## Installation Guide for Priism in Conda Environments

### Notes

- This installation process has been tested on Linux (Archlinux and OpenSUSE), and it should also work for other Linux distributions. However, it has **not** been tested on macOS.
- We recommend using **Miniforge** or **Miniconda** for this installation, as they are free and open-source. However, please note that access to **Anaconda’s public repository** of packages is only free for individuals and small organizations (fewer than 200 employees). A paid license is required for larger organizations or those embedding/mirroring Anaconda’s repository. For more details, refer to [Anaconda's terms of service](https://www.anaconda.com/terms-of-service).
- Using **Miniforge**, which is configured to use the **conda-forge** channel by default, is a good alternative if you want to avoid licensing concerns related to Anaconda’s repository.
- Ensure you have the appropriate permissions for copying files and modifying your environment.


### Step-by-Step Installation Instructions

1. **Create a new conda environment:**
```bash
conda create -n priism python=3.10
```

2. **Activate the environment:**
```bash
conda activate priism
```

3. **Install Jupyter and necessary dependencies:**
```bash
conda install conda-forge::jupyter
conda install conda-forge::astropy
```


4. **Clone the PRIISM repository from GitHub:**
```bash
git clone https://github.com/tnakazato/priism.git
```

5. **Navigate into the project directory and update the repository:**
```bash
cd priism
git pull
```

6. **Install required Python packages:**
- This will install all necessary dependencies, including `casatasks` and `casatools`
```bash
python -m pip install -r requirements.txt
```

7. **Install the newest version of GCC (Optinal):**
- If you encounter an error like "GLIBCXX_x.x.xx' not found" during the build process, install the latest version of GCC via:
```bash
conda install conda-forge::gcc
```

8. **Manually copy the Python library (`libpython3.10.a`):**
- Download the latest CASA package from the official website, locate the `libpython3.10.a` file (typically found in `/your_casa_folder/lib/py/lib`).
- Copy the file to the `lib` folder of your `priism` environment (typically `/your_conda_folder/envs/priism/lib/`).

9. **Ensure that the `~/.casa/data` folder exists:**
- If it doesn’t exist, create the folder:
```bash
mkdir -p ~/.casa/data
```

10. **Build the project:**
```bash
python setup.py build
```

11. **Install the project:**
```bash
python setup.py install
```

12. **Installation Complete!**
- The Priism package should now be installed and ready to use in the `priism` environment. You can start exploring the tutorials to get familiar with its functionalities.


---

Feel free to add any more instructions or troubleshooting tips as needed.
34 changes: 26 additions & 8 deletions python/priism/core/imager.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,19 @@ def __init__(self, nv, nh, L1_list, Ltsv_list):
self.axes_list = collections.defaultdict(dict)

def plotimage(self, L1, Ltsv, data, mse):
assert L1 in self.L1_list
assert Ltsv in self.Ltsv_list
row = np.where(self.L1_list == L1)[0][0]
column = np.where(self.Ltsv_list == Ltsv)[0][0]

# Use np.isclose for tolerance-based comparisons
# assert L1 in self.L1_list
# assert Ltsv in self.Ltsv_list
assert any(np.isclose(L1, val) for val in self.L1_list), f"L1: {L1} not found in L1_list"
assert any(np.isclose(Ltsv, val) for val in self.Ltsv_list), f"Ltsv: {Ltsv} not found in Ltsv_list"

# Find the index using np.isclose for tolerance-based matching
# row = np.where(self.L1_list == L1)[0][0]
# column = np.where(self.Ltsv_list == Ltsv)[0][0]
row = np.where(np.isclose(self.L1_list, L1))[0][0]
column = np.where(np.isclose(self.Ltsv_list, Ltsv))[0][0]

cx = self.outer_frame.left_margin + (column + 0.5) * self.outer_frame.dx
cy = self.outer_frame.bottom_margin + (row + 0.5) * self.outer_frame.dy
left = cx - self.image_width / 2
Expand All @@ -751,10 +760,19 @@ def plotimage(self, L1, Ltsv, data, mse):
self.axes_list[row][column] = a

def mark_bestimage(self, L1, Ltsv):
assert L1 in self.L1_list
assert Ltsv in self.Ltsv_list
row = np.where(self.L1_list == L1)[0][0]
column = np.where(self.Ltsv_list == Ltsv)[0][0]

# Use np.isclose for tolerance-based comparisons
# assert L1 in self.L1_list
# assert Ltsv in self.Ltsv_list
assert any(np.isclose(L1, val) for val in self.L1_list), f"L1: {L1} not found in L1_list"
assert any(np.isclose(Ltsv, val) for val in self.Ltsv_list), f"Ltsv: {Ltsv} not found in Ltsv_list"

# Find the index using np.isclose for tolerance-based matching
# row = np.where(self.L1_list == L1)[0][0]
# column = np.where(self.Ltsv_list == Ltsv)[0][0]
row = np.where(np.isclose(self.L1_list, L1))[0][0]
column = np.where(np.isclose(self.Ltsv_list, Ltsv))[0][0]

best_axes = self.axes_list[row][column]
bbox = best_axes.get_position()
if int(matplotlib.__version__.split('.')[0]) > 1:
Expand Down
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,21 @@ def get_python_library(include_dir):
libnames.append(libname2)

libpath = sysconfig.get_config_var('LIBDIR')
print(f"Trying library names: {libnames}")
print(f"Checking in libpath: {libpath}")

for libname in libnames:
pylib = os.path.join(libpath, libname)
print(f"Checking {pylib}")
if os.path.exists(pylib):
return pylib

libpath2 = os.path.join(libpath, sysconfig.get_config_var('MULTIARCH'))
print(f"Checking in libpath2: {libpath2}")

for libname in libnames:
pylib = os.path.join(libpath2, libname)
print(f"Checking {pylib}")
if os.path.exists(pylib):
return pylib

Expand All @@ -184,17 +191,23 @@ def get_python_library(include_dir):

for l in ['lib', 'lib64']:
libpath = os.path.join(prefix, l)
print(f"Checking in {libpath}")

for libname in libnames:
pylib = os.path.join(libpath, libname)
print(f"Checking {pylib}")
if os.path.exists(pylib):
return pylib

libpath2 = os.path.join(libpath, sysconfig.get_config_var('MULTIARCH'))
for libname in libnames:
pylib = os.path.join(libpath2, libname)
print(f"Checking {pylib}")
if os.path.exists(pylib):
return pylib

# Print out a helpful error message instead of just failing
print(f"Failed to find Python library in {libnames}")
assert False


Expand Down
4 changes: 2 additions & 2 deletions tutorial_hltau.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"source": [
"Sample data for the tutorial is the protoplanetary disk \"**HL Tau**\" observed at Band 6 with long baselines of ALMA 12m array as part of [science verification](https://almascience.nao.ac.jp/alma-data/science-verification). The calibration information can be obtained from [CASA Guide](https://casaguides.nrao.edu/index.php?title=ALMA2014_LBC_SVDATA#HL_Tau_-_Protoplanetary_Disk), and the data can be downloaded from the link below: \n",
"\n",
"https://alma-dl.mtk.nao.ac.jp/ftp/alma/sciver/HLTauBand6/HLTau_Band6_CalibratedData.tgz\n",
"https://almascience.nao.ac.jp/almadata/sciver/HLTauBand6/HLTau_Band6_CalibratedData.tgz\n",
"\n",
"After you download the data, you should extract the MS from the file. You may run the following cell to obtain the dataset."
]
Expand All @@ -111,7 +111,7 @@
"%%bash\n",
"\n",
"# download if necessary\n",
"[ -e HLTau_Band6_CalibratedData.tgz ] || wget -nv https://alma-dl.mtk.nao.ac.jp/ftp/alma/sciver/HLTauBand6/HLTau_Band6_CalibratedData.tgz\n",
"[ -e HLTau_Band6_CalibratedData.tgz ] || wget -nv https://almascience.nao.ac.jp/almadata/sciver/HLTauBand6/HLTau_Band6_CalibratedData.tgz\n",
"\n",
"# extract data from tar-ball\n",
"[ -e HLTau_Band6_CalibratedData ] || tar xf HLTau_Band6_CalibratedData.tgz"
Expand Down
Loading