Group Abstract Group Abstract

Message Boards Message Boards

0
|
615 Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Import[] is changing the context and with it fails to import the file I want

Posted 3 months ago

I have this small notebook snippet. This one was working about a year ago.

In[4]:= (* Set HistoryLength *)
$HistoryLength = 1;
(* Set working directory *)
SetDirectory["/Volumes/Data/Projects/SpeckleSH/Data"];
Directory[]

Out[6]= "/Volumes/Data/Projects/SpeckleSH/Data"

(* Read fits files. Scientific contains 999 pictures, \
waveform contains 2000 pictures *)
fps = Import["/Volumes/Data/Projects/SpeckleSH/Data/q880_0284.fits", 
   "RawData"];
fps[[1, 1]]

In[1]:= Directory[]

Out[1]= "/Volumes/Home/janos"

In[1]:= fps // Length

Out[1]= 0

So, Import[] is changing the directory specified by SetDirectory back to the user home directory, and cannot find the file, although it is specified with a full path. What is wrong here? Thanks ahead, János

POSTED BY: Janos Lobb
3 Replies
Posted 3 months ago
POSTED BY: Janos Lobb
Posted 3 months ago

Well, I am on a MacBook Air M1 and when I ran that small notebook I was on 10.15.1. I upgraded yesterday to 10.15.6 and following that to Tahoe 26.1. Mathematica version is "Wolfram 14.3.0.11930707".

In the meantime I decided not to use Import because I had similar experiences 11 years ago working with .fits files. I will just use OpenRead and BinaryRead to read from the fits file the header and data. The fits file itself contain astronomical data between 1000 and 3000, 256x256 grayscale images 16 bits. Nothing especially extra . But thanks for looking into this Import, although now looks like it became not so Import-ant for me. Best, János

POSTED BY: Janos Lobb
Posted 3 months ago

I cannot reproduce. Based on what you're showing, I assume there was something about the data that caused the kernel to crash. You don't show any output for fps[[1,1]], and that would be consistent with the kernel crashing and therefore not evaluating fps[[1,1]], If you then evaluated the expressions following that, the output you showed would also be consistent with a crash, e.g. Directory[] pointing to your home directory. So I would check your data. It might be too large or malformed somehow.

Just in case that's not the explanation, you might want to provide your Mathematica version and your operating system to better help debug.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard