Is there an equivalent of FSC_COLOR in GDL? - idl

I am trying to run my IDL programs at home in GDL. Among other problems I run into this one:
GDL> bk=fsc_color('Black')
% Ambiguous: Variable is undefined: FSC_COLOR or: Function not found: FSC_COLOR
% Execution halted at: $MAIN$
Is there a way to get colours by name in GDL?

This sounds like you just haven't put fsc_color.pro in your !path (or the GDL equivalent). FSC_COLOR is not provided by the IDL distribution; you have to install it and tell IDL where it is located.

Related

What are ppearson and spearson in datamash, and how do you use them?

When I look at the documentation, there is no "correlation", but there is "ppearson" and "spearson". They are mentioned exactly once, as a "group-by statistical operation." But .. how exactly are they defined?
Also, when I try to use one, there is an error message, but I don't understand how to fix it. How do you use ppearson or spearson?
$ cat > foo.tsv
1^I2
2^I3
$ cat foo.tsv | datamash ppearson 1,2
datamash: operation ‘ppearson’ requires field pairs
EDIT: This documentation section says
GNU Datamash is designed to closely follow R project’s (https://www.r-project.org/) statistical functions. See the files/operators.R file for the R equivalent code for each of datamash’s operators. When building datamash from source code on your local computer, operators are compared to known results of the equivalent R functions.
Looking in R, I don't see an spearson:
> ?spearson
No documentation for ‘spearson’ in specified packages and libraries:
you could try ‘??spearson’

Can't get AllegroServe / Ironclad to work

(ql:quickload "aserve") fails
I'm trying to install AllegroServe. According to http://quickdocs.org/portableaserve/ and to this SO thread the simplest way to get aserve would be to get it with quicklisp: (ql:quickload "aserve")
But (ql:quickload "aserve") fails yielding the following error in the debugger buffer:
COMPILE-FILE-ERROR while compiling
#<IRONCLAD-SOURCE-FILE "ironclad" "src" "digests" "digest">
[Condition of type UIOP/LISP-BUILD:COMPILE-FILE-ERROR]
Whereas in the REPL it says:
; Loading "aserve"
; caught ERROR: READ error during COMPILE-FILE: Symbol "BIGNUM-TYPE"
; not found in the SB-BIGNUM package. Line: 53, Column: 52,
; File-Position: 2151 Stream: #<SB-INT:FORM-TRACKING-STREAM for
; "file
; C:\\Users\\user\\AppData\\Roaming\\quicklisp\\dists\\quicklisp\\software\\ironclad_0.33.0\\src\\digests\\digest.lisp"
; {25AFCD91}>
What I've tried so far
Apparently ironclad is another package, a "cryptographic toolkit written in pure Common Lisp". I downloaded ironclad-v0.34 from http://quickdocs.org/ironclad/ and even found digest.lisp and digests.lisp in the ironclad folder which made me think that I am on the right track.
My problem is I don't no where to go from here. How and where do I "install" ironclad?
Quickdocs says
[ironclad] comes with an ASDF system definition, so (asdf:oos 'asdf:load-op
:ironclad) should be all that you need to get started. The testsuite
can be run by substituting asdf:test-op for asdf:load-op in the form
above.
but since I'm not familiar with asdf I don't know what to make of it.
Am I even on the right track? Is installing the ironclad package the right way to make the error COMPILE-FILE-ERROR while compiling #<IRONCLAD-SOURCE-FILE "ironclad" "src" "digests" "digest">go away? If so what do I do with the ironclad-v0.34 folder?
(I'm using sbcl on a windows 10 machine.)
Thanks to #jkiiski leading me down the right path I was able to install aserve. The problem was indeed an old version of ironclad which, as #jkiiski pointed out, was using SB-BIGNUM:BIGNUM-TYPE which had been removed from SBCL.
However, the way I updated ironclad is probably NOT(!) a good way because I did it all manually (error prone).
Not knowing how quicklisp works exactly I searched for every occurence of ironclad-0.33.0 and replaced it with ironclad-v0.34, which meant replacing
the .../dists/quicklisp/software/ironclad-0.33.0 folder with .../dists/quicklisp/software/ironclad-v0.34
the irconcladd-0.33.0 tgz in .../dists/quicklisp/archives/ with ironclad-v0.34.tgz
the entry dists/quicklisp/software/ironclad-0.33.0/ in .../dists/quicklisp/installed/releases/ironclad.txt with dists/quicklisp/software/ironclad-v0.34/.
I also updated ironclad.txt and ironclad-text.txt in .../dists/quicklisp/installed/systems/
Well, it worked, but I only did it this way because I don't know any better (but am sure there has to be a better way).

Call Rmath via Ctypes from Ocaml on OS X

I want to use R's mathematical functions as provided in libRmath from Ocaml. I successfully installed the library via brew tap homebrew science && brew install --with-librmath-only r. I end up with a .dylib in /usr/local/lib and a .h in /usr/local/include. Following the Ocaml ctypes tutorial, i do this in utop
#require "ctypes.foreign";;
open Ctypes;;
open Foreign;;
let test_pow = foreign "pow_di" (float #-> int #-> returning float);;
this complains that it can't find the symbol. What am I doing wrong? Do I need to open the dynamic library first? Set some environment variables? After googling, I also did this:
nm -gU /usr/local/lib/libRmath.dylib
which gives a bunch of symbols all with a leading underscore including 00000000000013ff T _R_pow_di. In the header file, pow_di is defined via some #define directive from _R_pow_di. I did try variations of the name like "R_pow_di" etc.
Edit: I tried compiling a simple C program using Rmath using Xcode. After setting the include path manually to include /usr/local/include, Xcode can find the header file Rmath.h. However, inside the header file, there is an include of R_ext/Boolean.h which does not seem to exist. This error is flagged by Xcode and compilation stops.
Noob alert: this may be totally obvious to a C programmer...
In order to use external library you still need to link. There're at least two different ways, either link using compiler, or link even more dynamically using dlopen.
For the first method use the following command (as an initial approximation):
ocamlbuild -pkg ctypes.foreign -lflags -cclib,-lRmath yourapp.native
under premise that your code is put into yourapp.ml file.
The second method is to use ctypes interface to dlopen to open the library. Using the correct types and name for the C function call, this goes like this:
let library = Dl.dlopen ~filename:"libRmath.dylib" ~flags:[]
let test_pow = foreign ~from:library "R_pow_di" (double #-> int #-> returning double)

Julia: dollar sign in command without single quotes

I am trying to run the following command from Julia:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/.julia/v0.3/Smile/deps/downloads
When I run it as-is it tries to replace $LD_LIBRARY_PATH with a local variable.
When I escape the $, it puts quotes around the command, which invalidates it.
julia> cmd = `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/tim/.julia/v0.3/Smile/deps/downloads`
ERROR: LD_LIBRARY_PATH not defined
julia> cmd = `export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/home/tim/.julia/v0.3/Smile/deps/downloads`
`export 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/tim/.julia/v0.3/Smile/deps/downloads'`
I would like to run the command in a form similar to:
run(`export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$newpath`)
How do I properly handle the dollar sign?
Thank you
*note: pasting the command directly into terminal and running it does work
In Julia, backticks are not completely equivalent to running the corresponding command at the shell. You can't interpolate environmental variables with $ (although $(get(ENV, "varname", "") should match the shell's behavior), and export is a shell built-in, not a command, so I don't think you can run it. Also, even if backticks shelled out, export would only change the environment of the subshell, not the calling process.
You should be able to set LD_LIBRARY_PATH from Julia as:
ENV["LD_LIBRARY_PATH"] = "$(get(ENV, "LD_LIBRARY_PATH", "")):$newpath"
but you should avoid this if possible. If your intent is to ccall a specific library, you can pass the library path directly to ccall, perhaps using find_library as you indicated in a comment if you don't know the full path advance. If you need to set LD_LIBRARY_PATH because the library needs to load other libraries, I'm not sure if there's a better way, but note that LD_LIBRARY_PATH is platform-specific. You might be able to dlopen the dependent libraries first, but I haven't tested that.

Problems with spaces in paths when calling a batch file from R

I have some problems to call a command line program called molconvert from R using system() in Windows. molconvert is located in "C:\Program Files\ChemAxon\MarvinBeans\bin"
I would then like to invoke system() or shell() to mimick what I would achieve by typing
molconvert pdb "C:\molecule conversions\cembrene A.mol"
at the command prompt and collect the resulting output back to R as in
out=system(...,intern=T)
I seem to have trouble though with the backslashes and the spaces in the paths.
I tried with
dirmolconvert="C:\\Program Files\\ChemAxon\\MarvinBeans\\bin"
shell(shQuote(paste(dirmolconvert,"\\molconvert pdb "C:\\cembrene A.mol",sep="")))
but that gives me "Error: unexpected symbol in ..." and escaping the " also doesn't help. Any thoughts on how I should resolve this?
or
system(paste(dirmolconvert,"\\molconvert pdb \"C:\\cembrene A.mol\"",sep=""), intern=T)
but that gives me
'C:\Program' not found
Any thoughts?
Edit:
Based on the answer below the right way to do this apparently is
inputdir="C:/Users/Ento/Documents/GCMS/molconvert test"
molconvertdir="C:/Program Files/ChemAxon/MarvinBeans/bin"
molecule="cembrene A.mol"
out=system(paste(shQuote(file.path(molconvertdir, "molconvert.bat")),
"pdb",
shQuote(file.path(inputdir,molecule))),intern=T)
You want to use shQuote to quote the path to the executable, not the entire command line. Depending on what your molconvert program expects, you may also want to quote paths that are arguments to it.
system(paste(shQuote(file.path(dirmolconvert, "molconvert.exe")),
"pdb",
shQuote("C:\\molecule conversions\\cembrene A.mol"))
the easiest way to fix this is to use short paths:
for %%a in ("C:\molecule conversions\cembrene A.mol") set "sh_path=%%~dpfnxsa"
or
for %%a in ("C:\Program Files\ChemAxon\MarvinBeans\bin") do set "pf_sh_path=%%~dpfnxsa"
and then to pass %sh_path% and %pf_sh_path% as parameter.

Resources