pearl-pmsco-import.ipf
Go to the documentation of this file.
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma IgorVersion = 6.2
#pragma ModuleName = PearlPmscoImport
// copyright (c) 2018 Paul Scherrer Institut
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http:///www.apache.org/licenses/LICENSE-2.0
//
// Please acknowledge the use of this code.
function /s pmsco_save_scan(pathname, filename, energy, theta, phi, alpha, intensity, sigma, [sdfr])
string pathname
string filename
string energy
string theta
string phi
string alpha
string intensity
string sigma
dfref sdfr
//string fileext
//fileext = StringFromList(ItemsInList(filename, ".") - 1, filename, ".")
dfref savedf = GetDataFolderDFR()
dfref tempdf = NewFreeDataFolder()
if (ParamIsDefault(sdfr))
dfref sdfr = savedf
endif
SetDataFolder sdfr
wave w_intensity = $intensity
string wavenames = ""
wavenames = save_scan_helper("w_energy", energy, w_intensity, tempdf, wavenames)
wavenames = save_scan_helper("w_theta", theta, w_intensity, tempdf, wavenames)
wavenames = save_scan_helper("w_phi", phi, w_intensity, tempdf, wavenames)
wavenames = save_scan_helper("w_alpha", alpha, w_intensity, tempdf, wavenames)
wavenames = save_scan_helper("w_intensity", intensity, w_intensity, tempdf, wavenames)
wavenames = save_scan_helper("w_sigma", sigma, w_intensity, tempdf, wavenames)
setdatafolder tempdf
save /b /g /m="\n" /p=$pathname wavenames as filename
setdatafolder savedf
end
static function /s save_scan_helper(destname, value, template, destdfr, wavenames)
string destname
string value
wave template
dfref destdfr
string wavenames
variable err = 0
if (strlen(value) > 0)
if (exists(value) == 1)
duplicate $value, destdfr:$destname
wave /sdfr=destdfr w=$destname
else
duplicate template, destdfr:$destname
wave /sdfr=destdfr w=$destname
variable numval = str2num(value)
string msg
if (numtype(numval) == 0)
w = numval
//elseif (cmpstr(value[0,0], "%") == 0)
else
strswitch(value)
case "x":
w = DimOffset(template, 0) + DimDelta(template, 0) * p
break
case "y":
w = DimOffset(template, 1) + DimDelta(template, 1) * q
break
case "z":
w = DimOffset(template, 2) + DimDelta(template, 2) * r
break
case "t":
w = DimOffset(template, 3) + DimDelta(template, 3) * s
break
default:
err = 1
sprintf msg, "invalid %s argument", StringFromList(1, destname, "_")
endswitch
endif
endif
if (err == 0)
wavenames = AddListItem(destname, wavenames, ";", inf)
variable npts = DimSize(w, 0) * max(DimSize(w, 1), 1) * max(DimSize(w, 2), 1) * max(DimSize(w, 3), 1)
Redimension /n=(npts) w
else
abort msg
endif
endif
return wavenames
end
function /s pmsco_load_xyz(pathname, filename)
string pathname
string filename
string cis = "N=at;N=xx;N=yy;N=zz;"
LoadWave /A /B=cis /J /K=0 /L={0, 2, 0, 0, 0} /V={" ", " ", 0, 0} /O /P=$pathname filename
wave /t at
at = unpadstring(at, 32)
end
pmsco_save_scan
string pmsco_save_scan(string pathname, string filename, string energy, string theta, string phi, string alpha, string intensity, string sigma, dfref sdfr=defaultValue)
save waves in a PMSCO scan data file.
Definition: pearl-pmsco-import.ipf:88
save_scan_helper
static string save_scan_helper(string destname, string value, wave template, dfref destdfr, string wavenames)
helper function for save_pmsco_scan()
Definition: pearl-pmsco-import.ipf:126
pmsco_load_xyz
string pmsco_load_xyz(string pathname, string filename)
load an xyz cluster file
Definition: pearl-pmsco-import.ipf:188