Sunday, July 23, 2017

ISIS3 on Windows 10 Bash

Based on a tweet by MarsLakes, I also decided to give ISIS3 on Windows 10 a try. Note this is for Windows 10 Anniversary update or higher. Anyway, here is my current cheat sheet. It works better that I thought it would but still has GUI issues. However, using this environment as a processing machine - seems to work like a charm. Warning: this requires a lot of downloading.

(1) get Bash on Windows 10
short cuts:
-- In Windows head to Settings > Update & Security > For Developers > Developer Mode
-- Next, find "Turn Windows Features On or Off" -- and check on "Windows Subsystem for Linux"
-- reboot and start Bash from the  Windows' start bar.
for picture instructions see:
or

(2) update Bash (just in case)
> sudo apt-get update 
-- this just gets your Ubuntu system up to date. It is worth running this at the end too.

(3) For Windows, install Xming and launch

(4) From Windows, start bash and let's get the GUI working.
> sudo apt install x11-apps
> sudo apt-get install lxde

(5) To solve a missing library, download this package and install: https://packages.ubuntu.com/trusty/amd64/libicu52/download
or  run these lines:
> sudo dpkg -i libicu52_52.1-3ubuntu0.6_amd64.deb

(optional...?). I didn't have an issue with this missing lib, but here is a potential helpful comment from another user who was missing this library -- which he solved by running:
> sudo apt-get install libnss3-1d

(6) Get ISIS3
> cd ~
> mkdir isis3
> cd isis3
> rsync -azv --delete --partial isisdist.astrogeology.usgs.gov::x86-64_linux_UBUNTU/isis .
> rsync -azv --delete --partial isisdist.astrogeology.usgs.gov::isis3data/data/base data/
-- optional for testing CTX processing below (which doesn't require image kernels)
> rsync -azv --delete --partial --exclude='kernels' isisdist.astrogeology.usgs.gov::isis3data/data/mro data/
> cd ~

> vi .bashrc
or for a GUI editor
> sudo apt-get install gedit
> gedit .bashrc
## add these lines to bottom of .bashrc
export DISPLAY=:0

ISISROOT=~/isis3/isis
export ISISROOT
.  $ISISROOT/scripts/isis3Startup.sh
## end of add lines

6.1) close your Bash terminal and restart it. This will now initialize ISIS3 in your new terminal.
-- Try something (I still get a warning but it seems to work). The warning is QXcbConnection: XCB error: 170 for future reference
> qview $ISIS3DATA/base/dems/MSGR_DEM_USG_EQ_I_V02_prep.cub
-- BTW, LOLA DEM opened but MOLA didn't...? Same size so odd

(7) Test a Linux windowing env. (not really needed and it is still awkward).
> startlxde
-- Use "cntl c" to kill it.

(8) Download other packages for testing the GUI
> sudo apt-get install synaptic
> sudo synaptic
-- try to search and install firefox
-- once installed, launch firefix
> firefox

(9) to run a test CTX image in ISIS3
> sudo apt-get install csh
> cd ~
> mkdir isis3_test
> cd isis3_test
> chmod +x CTX_process_all.csh
> printf "Group = Mapping\n  ProjectionName  = SimpleCylindrical\n   CenterLongitude = 0.0\n  CenterLatitude  = 0.0\nEnd_Group\nEnd" > simp0.map
> ./CTX_process_all.csh simp0.map  0
-- wait several minutes for ISIS3 to do its thing.
> qview P22_009816_1745_XI_05S073W.lev1eo.cub
example: qview with CTX P22_009816_1745_XI_05S073W calibrated only



> sudo apt-get install gpicview
> gpicview P22_009816_1745_XI_05S073W.png
example: gpicview with CTX P22_009816_1745_XI_05S073W.png all map projected


(10) Now use GDAL to create a GIS-ready image (GeoTiff) not just a PNG. 
> sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
-- Hit enter when prompted, then:
> sudo apt-get install gdal-bin
-- First stretch to 8bit using ISIS3 (0.5% to 99.5% linear stretch -- optional):
stretch from=P22_009816_1745_XI_05S073W.lev2.cub to=P22_009816_1745_XI_05S073W_8bit.cub+8bit+
1:254 USEPERCENTAGES=true pairs="0:1 0.5:1 99.5:254 100:254" null=0 lis=1 lrs=1 his=255 hrs=255
> gdal_translate P22_009816_1745_XI_05S073W_8bit.cub P22_009816_1745_XI_05S073W_8bit.tif
> gpicview P22_009816_1745_XI_05S073W_8bit.tif



(11) Now run ISIS commands from (really a shell script) from Powershell. I guess this means ArcMap or Socet GXP might be able to run ISIS3 commands. hmmm...?

From Windows, start powershell (not the (x86) version). From the horrible blue background (do yourself a favor and turn the background black) run:
> bash -i -c "cd /home/thare/isis3_test ; ./CTX_process_all.csh simp0.map  0"


-- so the trick here is the "-i" which setups the env. for ISIS3 and "-c" runs the command in quotes.
-- Also the Windows locations for /home/thare is here (you may need to show hidden files in Windows to see it): C:\Users\<WIN_USER>\AppData\Local\lxss\home\thare\
-- In Bash, your Windows files are: /mnt/c or /mnt/d, etc.
-- more tricks: https://www.howtogeek.com/262086/how-to-run-linux-commands-from-outside-the-bash-shell-on-windows-10/

reference: https://msdn.microsoft.com/en-us/commandline/wsl/faq





tip: To get an Anconda Python 3.x with GDAL
Once Miniconda w/ python 3 *.sh is installed, I had to update several missing items


conda install -c conda-forge mathplotlib
conda install -c conda-forge basemap

conda install -c conda-forge jupyter
conda install -c conda-forge gdal
-- and to fix gdal linking
conda install -c conda-forge xerces-c=3.1.4

conda install -c conda-forge kealib=1.4.7

When you run
jupyter notebook
you can then run the browser on the Windows-side using the link provided - cool.

No comments:

Post a Comment