u/ducks_over_IP

▲ 28 r/Julia

What's the most straightforward way to read and write numerical data from a file in Julia?

I'm interested in picking up Julia as a scientific computing language, hopefully to replace my current system of Fortran-for-speed and Python-for-convenience. However, I'm getting hung up on its file handling.

The issue is that in Julia, all of my options for file I/O look pretty confusing. The built-in read and write functionality seems to only take text input as strings, rather than as numeric types. The CSV package is powerful, but then it complicates things because it only returns a 'dataframe', whatever that is. Likewise, the documentation for CSV.write() says that it will "write a Tables.jl interface input to a csv file." All I want to do is read some numbers into a couple 1D arrays, do some math on them, then write them back out. I feel like I must be missing something stupidly obvious, because I don't understand why it seems so hard for Julia to do something that creaky old Fortran figured out decades ago.

To illustrate more clearly what I'm trying to do, sample code follows in Fortran 90 and Python. In both cases, the code reads an input file (file.txt) and stores the data in 1D arrays a and b. Then, assuming further computations follow producing 1D arrays x and y, those two arrays are written to a new file (file2.txt).

Fortran 90:

open(10, 'file.txt')

do i = 1, 10
   read(10, *) a(i), b(i)
end do

close(10)

...
(further computations on a and b, producing outputs x and y)
...

open(11, 'file2.txt')

do i = 1, 10
   write(10, *) x(i), Y(i)
end do

close(11)

Python:

a, b = numpy.loadtxt("file.txt", unpack=True)

...
(further computations on a and b, producing outputs x and y)
...

data = numpy.column_stack((x, y))

numpy.savetxt(file2.txt, data, fmt='%.16E', delimiter=' ')

As you can see, the Fortran method is a little clunky but very explicit about what it's doing, whereas the Python method is slick but requires a little extra formatting work.

reddit.com
u/ducks_over_IP — 2 days ago

How did the Pope gain his political power, particularly between the late Roman empire and the Investiture Controversy?

The Pope of the Catholic Church wears many hats, and not just the funny pope ones: leader of one of the world's largest religions, global advocate for peace to anyone who will listen (with varying success), steward (owner?) of countless artifacts and works of art, absolute monarch of a theocratic city-state, and (currently) White Sox fan.

But whereas the Pope is to most people a genteel old guy who wears funny hats and prays a lot (which may be good or bad depending on your point of view), once upon a time he wielded considerable political power in Europe, with personal rule over significant chunks of Italy and the ability to go toe-to-toe with European monarchs in political disputes. While the Pope today can usually get a foot in the door or at least a phone call wherever he wants, in 1077 he kept the Holy Roman Emperor waiting outside his castle for 3 days in the snow before allowing him in to beg forgiveness during the Investiture Controversy. That's a different level of power by anyone's measure, I'd say.

Of course, go back even further and the Pope of Rome is just one of several important Christian bishops in the Roman Empire, and arguably not even the most important one. Go back further than that and he's not important to anyone except the followers of this weird cult that came out of Judea. All of which is to say, how did the Pope go from his initial status as just the bishop of Rome to a significant power player in European politics?

reddit.com
u/ducks_over_IP — 13 days ago

I need to ssh into a supercomputer for research. Quite reasonably, they've implemented 2FA, so even with ssh keys I need to externally authenticate for every session. This would be no big deal, except I also need to transfer files back and forth fairly regularly. The only way I know to do this is via scp or rsync (or a GUI interface for the same like FileZilla), which requires me to go through the whole login song-and-dance again, even if I'm already logged in to an ssh session. Is there a way to transfer files between my local machine and the supercomputer within my current ssh session, so that I don't need to re-authenticate every time I want to download some data or upload a new program?

If what I'm asking for isn't possible, or this is the wrong sub, or you need more info, please let me know. Thanks in advance for your time.

  • Local OS: Windows 11 Home
  • Terminal emulator: Windows Terminal
  • Local SSH client: OpenSSH (Wnative) or Ubuntu OpenSSH under WSL2
  • Remote OS: Rocky Linux 9.7
reddit.com
u/ducks_over_IP — 15 days ago

I'm of course referring to the third verse of Lynyrd Skynyrd's classic rock song "Sweet Home Alabama", in which lead singer Ronnie Van Zandt declares:

>In Birmingham they love the governor
Now we all did what we could do
Now Watergate does not bother me
Does your conscience bother you? Tell me true

I understand that the governor of Alabama at the time was the infamous segregationist George Wallace, but he was a Southern Democrat, not a Republican like Nixon, so I don't understand what he has to do with Watergate. To my knowledge this was still in the era of the 'Solid South', so it also seems like if anything Watergate should have been an opportunity for a Southern band to mock Nixon and the GOP more generally. Am I missing some important context?

reddit.com
u/ducks_over_IP — 18 days ago

For many people, especially those raised on the grunge and alternative rock of the 90s, nothing says dumb-jock rock excess like 80s hair metal. Def Leppard, Van Halen, Poison, Whitesnake, Mötley Crüe, Guns 'n' Roses—these bands presented themselves in their music as stereotypically macho and sex-obsessed, as exemplified by songs like "Girls, Girls, Girls", "Cherry Pie", and "Pour Some Sugar On Me", but adopted a visual style that arguably verged on drag, with long permed hair, makeup, feather boas, and lots of skintight leather. One imagines that if they wore their stage outfits to a contemporary high school, they'd be bullied for "looking gay" by the very same kids that listened to their music. What explains the apparent dissonance between these bands' very macho sound and very not-macho appearance?

reddit.com
u/ducks_over_IP — 21 days ago

When portrayed during or just after the Crucifixion, Jesus is commonly depicted wearing a loincloth, to the point that it's basically the standard representation, as evidenced by the gallery on Wikipedia. Does the loincloth actually reflect typical undergarments at the time, and would Roman practice have left it on him during crucifixion? It seems like they wouldn't particularly care about letting a condemned man keep a shred of dignity while subjecting him to the most undignified execution they could devise, but then again, they might also not have bothered to take it off. This excellent off-sub discussion by u/Spencer_A_McDaniel goes over his probable clothing, but it's unclear whether the chiton would be his only undergarment, or if he would have had a loincloth as well.

u/ducks_over_IP — 25 days ago