bugfixes in anglescan process: nicknames and interpolation
- nickname can now correctly reference a dataset in a subfolder. - the interpolation now trims the dataset at the largest angle.
This commit is contained in:
@ -1375,13 +1375,9 @@ function duplicate_hemi_scan(source_nickname, dest_folder, dest_nickname, [xpdpl
|
||||
dfref savedf = getdatafolderdfr()
|
||||
|
||||
// source data
|
||||
if (strlen(source_nickname))
|
||||
string s_prefix = source_nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref source_df = find_hemi_data(source_nickname, s_prefix, s_int)
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
string s_theta = s_prefix + "th"
|
||||
@ -1389,13 +1385,13 @@ function duplicate_hemi_scan(source_nickname, dest_folder, dest_nickname, [xpdpl
|
||||
string s_weight = s_prefix + "wt"
|
||||
string s_matrix = s_prefix + "matrix"
|
||||
|
||||
wave theta1 = $s_theta
|
||||
wave polar1 = $s_polar
|
||||
wave azim1 = $s_azim
|
||||
wave tot1 = $s_tot
|
||||
wave weight1 = $s_weight
|
||||
wave values1 = $s_int
|
||||
wave /z matrix1 = $s_matrix
|
||||
wave /sdfr=source_df theta1 = $s_theta
|
||||
wave /sdfr=source_df polar1 = $s_polar
|
||||
wave /sdfr=source_df azim1 = $s_azim
|
||||
wave /sdfr=source_df tot1 = $s_tot
|
||||
wave /sdfr=source_df weight1 = $s_weight
|
||||
wave /sdfr=source_df values1 = $s_int
|
||||
wave /sdfr=source_df /z matrix1 = $s_matrix
|
||||
|
||||
variable npol = numpnts(theta1)
|
||||
|
||||
@ -1403,13 +1399,7 @@ function duplicate_hemi_scan(source_nickname, dest_folder, dest_nickname, [xpdpl
|
||||
make_hemi_grid(npol, dest_nickname, xpdplot=xpdplot)
|
||||
|
||||
// dest data
|
||||
if (strlen(dest_nickname))
|
||||
s_prefix = dest_nickname + "_"
|
||||
s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
dfref dest_df = find_hemi_data(dest_nickname, s_prefix, s_int)
|
||||
s_polar = s_prefix + "pol"
|
||||
s_azim = s_prefix + "az"
|
||||
s_theta = s_prefix + "th"
|
||||
@ -1417,17 +1407,18 @@ function duplicate_hemi_scan(source_nickname, dest_folder, dest_nickname, [xpdpl
|
||||
s_weight = s_prefix + "wt"
|
||||
s_matrix = s_prefix + "matrix"
|
||||
|
||||
wave theta2 = $s_theta
|
||||
wave polar2 = $s_polar
|
||||
wave azim2 = $s_azim
|
||||
wave tot2 = $s_tot
|
||||
wave weight2 = $s_weight
|
||||
wave values2 = $s_int
|
||||
wave /sdfr=dest_df theta2 = $s_theta
|
||||
wave /sdfr=dest_df polar2 = $s_polar
|
||||
wave /sdfr=dest_df azim2 = $s_azim
|
||||
wave /sdfr=dest_df tot2 = $s_tot
|
||||
wave /sdfr=dest_df weight2 = $s_weight
|
||||
wave /sdfr=dest_df values2 = $s_int
|
||||
|
||||
tot2 = tot1
|
||||
weight2 = weight1
|
||||
values2 = values1
|
||||
if (waveexists(matrix1))
|
||||
setdatafolder dest_df
|
||||
duplicate /o matrix1, $s_matrix
|
||||
endif
|
||||
|
||||
@ -1452,23 +1443,20 @@ function rotate_hemi_scan(nickname, angle)
|
||||
|
||||
dfref savedf = getdatafolderdfr()
|
||||
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
string s_tot = s_prefix + "tot"
|
||||
string s_weight = s_prefix + "wt"
|
||||
|
||||
wave polar = $s_polar
|
||||
wave azim = $s_azim
|
||||
wave tot = $s_tot
|
||||
wave weight = $s_weight
|
||||
wave values = $s_int
|
||||
wave /sdfr=df polar = $s_polar
|
||||
wave /sdfr=df azim = $s_azim
|
||||
wave /sdfr=df tot = $s_tot
|
||||
wave /sdfr=df weight = $s_weight
|
||||
wave /sdfr=df values = $s_int
|
||||
|
||||
azim += angle
|
||||
azim = azim < 0 ? azim + 360 : azim
|
||||
@ -1533,6 +1521,8 @@ function /s display_hemi_scan(nickname, [projection, graphtype, do_ticks, do_gri
|
||||
variable do_grids
|
||||
string graphname
|
||||
|
||||
dfref savedf = getdatafolderdfr()
|
||||
|
||||
if (ParamIsDefault(projection))
|
||||
projection = 1
|
||||
endif
|
||||
@ -1554,22 +1544,20 @@ function /s display_hemi_scan(nickname, [projection, graphtype, do_ticks, do_gri
|
||||
endif
|
||||
|
||||
// hemi grid waves
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
string s_matrix = s_prefix + "matrix"
|
||||
|
||||
wave /z values = $s_int
|
||||
wave /z azim = $s_azim
|
||||
wave /z polar = $s_polar
|
||||
wave /z matrix = $s_matrix
|
||||
wave /sdfr=df /z values = $s_int
|
||||
wave /sdfr=df /z azim = $s_azim
|
||||
wave /sdfr=df /z polar = $s_polar
|
||||
wave /sdfr=df /z matrix = $s_matrix
|
||||
|
||||
setdatafolder df
|
||||
string s_ster_rad = s_prefix + "ster_rad"
|
||||
duplicate /o polar, $s_ster_rad /wave=ster_rad
|
||||
ster_rad = calc_graph_radius(polar, projection=projection)
|
||||
@ -1618,6 +1606,7 @@ function /s display_hemi_scan(nickname, [projection, graphtype, do_ticks, do_gri
|
||||
break
|
||||
endswitch
|
||||
|
||||
setdatafolder savedf
|
||||
return graphname
|
||||
end
|
||||
|
||||
@ -2241,15 +2230,14 @@ function set_polar_graph_cursor(nickname, cursorname, polar_angle, azim_angle, [
|
||||
endif
|
||||
endif
|
||||
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
else
|
||||
s_prefix = ""
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
wave /z azim = $s_azim
|
||||
wave /z polar = $s_polar
|
||||
wave /sdfr=df /z azim = $s_azim
|
||||
wave /sdfr=df /z polar = $s_polar
|
||||
|
||||
FindLevel /P /Q polar, polar_angle
|
||||
if (v_flag == 0)
|
||||
@ -2290,21 +2278,18 @@ function hemi_add_anglescan(nickname, values, polar, azi, [weights])
|
||||
endif
|
||||
|
||||
// quick check whether hemi grid is existing
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
string s_theta = s_prefix + "th"
|
||||
|
||||
wave /z w_values = $s_int
|
||||
wave /z w_azim = $s_azim
|
||||
wave /z w_polar = $s_polar
|
||||
wave /z w_theta = $s_theta
|
||||
wave /sdfr=df /z w_values = $s_int
|
||||
wave /sdfr=df /z w_azim = $s_azim
|
||||
wave /sdfr=df /z w_polar = $s_polar
|
||||
wave /sdfr=df /z w_theta = $s_theta
|
||||
if (!waveexists(w_values) || !waveexists(w_azim) || !waveexists(w_polar))
|
||||
abort "Missing hemispherical scan grid. Please call make_hemi_grid() first."
|
||||
endif
|
||||
@ -2361,13 +2346,10 @@ function hemi_add_aziscan(nickname, values, polar, azi, [weights])
|
||||
endif
|
||||
|
||||
// hemi grid waves
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_totals = s_prefix + "tot"
|
||||
string s_weights = s_prefix + "wt"
|
||||
string s_polar = s_prefix + "pol"
|
||||
@ -2377,15 +2359,15 @@ function hemi_add_aziscan(nickname, values, polar, azi, [weights])
|
||||
string s_dphi = s_prefix + "dphi"
|
||||
string s_nphis = s_prefix + "nphis"
|
||||
|
||||
wave w_polar = $s_polar
|
||||
wave w_azim = $s_azim
|
||||
wave w_values = $s_int
|
||||
wave w_totals = $s_totals
|
||||
wave w_weights = $s_weights
|
||||
wave w_index = $s_index
|
||||
wave w_theta = $s_theta
|
||||
wave w_dphi = $s_dphi
|
||||
wave w_nphis = $s_nphis
|
||||
wave /sdfr=df w_polar = $s_polar
|
||||
wave /sdfr=df w_azim = $s_azim
|
||||
wave /sdfr=df w_values = $s_int
|
||||
wave /sdfr=df w_totals = $s_totals
|
||||
wave /sdfr=df w_weights = $s_weights
|
||||
wave /sdfr=df w_index = $s_index
|
||||
wave /sdfr=df w_theta = $s_theta
|
||||
wave /sdfr=df w_dphi = $s_dphi
|
||||
wave /sdfr=df w_nphis = $s_nphis
|
||||
|
||||
// destination slice coordinates
|
||||
//polar = round(polar)
|
||||
@ -2441,32 +2423,38 @@ end
|
||||
|
||||
/// interpolate a hemispherical scan onto a rectangular grid
|
||||
///
|
||||
/// @warning experimental
|
||||
/// this function has been tested for one specific set of scan parameters.
|
||||
/// the interface and code may change at any time.
|
||||
/// the function depends on the ster_x and ster_y waves that are created by display_hemi_scan.
|
||||
/// the interpolated data is written to a new two-dimensional wave "matrix".
|
||||
/// the wave has a fixed size of 181 x 181 points optimized for 1-degree polar steps.
|
||||
///
|
||||
/// the function requires the ster_x and ster_y waves that are created by display_hemi_scan,
|
||||
/// and thus implicitly uses the same projection.
|
||||
///
|
||||
/// missing values (nan) are interpolated.
|
||||
/// this works well only if the missing values are reasonable sparse.
|
||||
/// the function also applies a gaussian filter to smooth the image.
|
||||
/// empty rings at high polar angles map are preserved.
|
||||
///
|
||||
/// to display the result call display_hemi_scan() with graphtype=3.
|
||||
///
|
||||
function interpolate_hemi_scan(nickname)
|
||||
string nickname
|
||||
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
dfref savedf = GetDataFolderDFR()
|
||||
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
string s_ster_x = s_prefix + "ster_x"
|
||||
string s_ster_y = s_prefix + "ster_y"
|
||||
|
||||
wave values = $s_int
|
||||
wave azim = $s_azim
|
||||
wave polar = $s_polar
|
||||
wave ster_x = $s_ster_x
|
||||
wave ster_y = $s_ster_y
|
||||
wave /sdfr=df values = $s_int
|
||||
wave /sdfr=df azim = $s_azim
|
||||
wave /sdfr=df polar = $s_polar
|
||||
wave /sdfr=df ster_x = $s_ster_x
|
||||
wave /sdfr=df ster_y = $s_ster_y
|
||||
|
||||
variable min_ster_x = wavemin(ster_x)
|
||||
variable max_ster_x = wavemax(ster_x)
|
||||
@ -2477,9 +2465,9 @@ function interpolate_hemi_scan(nickname)
|
||||
triplet[][0] = ster_x[p]
|
||||
triplet[][1] = ster_y[p]
|
||||
triplet[][2] = values[p]
|
||||
//ImageInterpolate /stw /s={x0, dx, xn, x0, dx, xn} voronoi triplet
|
||||
|
||||
variable size = 181
|
||||
setdatafolder df
|
||||
make /n=(size, size) /d /o $(s_prefix + "matrix") /wave=matrix
|
||||
make /n=(size, size) /free mnorm
|
||||
ImageFromXYZ /as {ster_x, ster_y, values}, matrix, mnorm
|
||||
@ -2487,7 +2475,12 @@ function interpolate_hemi_scan(nickname)
|
||||
matrixfilter NanZapMedian, matrix
|
||||
matrixfilter gauss, matrix
|
||||
|
||||
matrix = (x^2 + y^2) < 4 ? matrix : nan
|
||||
duplicate /free values, ster_finite
|
||||
ster_finite = (numtype(values) == 0) * (ster_x^2 + ster_y^2)
|
||||
variable ster_max = wavemax(ster_finite)
|
||||
matrix = (x^2 + y^2) <= ster_max ? matrix : nan
|
||||
|
||||
setdatafolder savedf
|
||||
end
|
||||
|
||||
/// map angle scan data onto a rectangular grid in stereographic projection
|
||||
@ -2619,25 +2612,22 @@ function save_hemi_scan(nickname, pathname, filename)
|
||||
dfref savedf = getdatafolderdfr()
|
||||
|
||||
// source data
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_polar = s_prefix + "pol"
|
||||
string s_azim = s_prefix + "az"
|
||||
string s_theta = s_prefix + "th"
|
||||
string s_tot = s_prefix + "tot"
|
||||
string s_weight = s_prefix + "wt"
|
||||
|
||||
wave theta1 = $s_theta
|
||||
wave polar1 = $s_polar
|
||||
wave azim1 = $s_azim
|
||||
wave tot1 = $s_tot
|
||||
wave weight1 = $s_weight
|
||||
wave values1 = $s_int
|
||||
wave /sdfr=df theta1 = $s_theta
|
||||
wave /sdfr=df polar1 = $s_polar
|
||||
wave /sdfr=df azim1 = $s_azim
|
||||
wave /sdfr=df tot1 = $s_tot
|
||||
wave /sdfr=df weight1 = $s_weight
|
||||
wave /sdfr=df values1 = $s_int
|
||||
|
||||
save /m="\r\n" /o /p=$pathname /t theta1, polar1, azim1, tot1, weight1, values1 as filename
|
||||
|
||||
@ -2749,21 +2739,18 @@ function trim_hemi_scan(nickname, theta_max)
|
||||
string nickname
|
||||
variable theta_max
|
||||
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_totals = s_prefix + "tot"
|
||||
string s_weights = s_prefix + "wt"
|
||||
string s_polar = s_prefix + "pol"
|
||||
|
||||
wave w_polar = $s_polar
|
||||
wave w_values = $s_int
|
||||
wave w_totals = $s_totals
|
||||
wave w_weights = $s_weights
|
||||
wave /sdfr=df w_polar = $s_polar
|
||||
wave /sdfr=df w_values = $s_int
|
||||
wave /sdfr=df w_totals = $s_totals
|
||||
wave /sdfr=df w_weights = $s_weights
|
||||
|
||||
w_values = w_polar <= theta_max ? w_totals / w_weights : nan
|
||||
end
|
||||
@ -2791,13 +2778,11 @@ function /wave hemi_polar_cut(nickname, azim)
|
||||
string nickname
|
||||
variable azim
|
||||
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
dfref savedf = getdatafolderdfr()
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_totals = s_prefix + "tot"
|
||||
string s_weights = s_prefix + "wt"
|
||||
string s_polar = s_prefix + "pol"
|
||||
@ -2809,15 +2794,15 @@ function /wave hemi_polar_cut(nickname, azim)
|
||||
string s_cut
|
||||
sprintf s_cut, "%s_azi%03u", s_int, round(azim)
|
||||
|
||||
wave w_polar = $s_polar
|
||||
wave w_azim = $s_azim
|
||||
wave w_values = $s_int
|
||||
wave w_totals = $s_totals
|
||||
wave w_weights = $s_weights
|
||||
wave w_index = $s_index
|
||||
wave w_theta = $s_theta
|
||||
wave w_dphi = $s_dphi
|
||||
wave w_nphis = $s_nphis
|
||||
wave /sdfr=df w_polar = $s_polar
|
||||
wave /sdfr=df w_azim = $s_azim
|
||||
wave /sdfr=df w_values = $s_int
|
||||
wave /sdfr=df w_totals = $s_totals
|
||||
wave /sdfr=df w_weights = $s_weights
|
||||
wave /sdfr=df w_index = $s_index
|
||||
wave /sdfr=df w_theta = $s_theta
|
||||
wave /sdfr=df w_dphi = $s_dphi
|
||||
wave /sdfr=df w_nphis = $s_nphis
|
||||
|
||||
variable npol = numpnts(w_theta)
|
||||
variable ipol
|
||||
@ -2825,6 +2810,8 @@ function /wave hemi_polar_cut(nickname, azim)
|
||||
variable pol
|
||||
variable pol1, pol2
|
||||
variable nsel
|
||||
|
||||
setdatafolder df
|
||||
make /n=(npol) /o $s_cut
|
||||
wave w_cut = $s_cut
|
||||
setscale /i x w_theta[0], w_theta[numpnts(w_theta)-1], "deg", w_cut
|
||||
@ -2850,6 +2837,8 @@ function /wave hemi_polar_cut(nickname, azim)
|
||||
w_cut[ipol] = nan
|
||||
endif
|
||||
endfor
|
||||
|
||||
setdatafolder savedf
|
||||
return w_cut
|
||||
end
|
||||
|
||||
@ -2875,13 +2864,11 @@ function /wave hemi_azi_cut(nickname, pol)
|
||||
string nickname
|
||||
variable pol
|
||||
|
||||
if (strlen(nickname))
|
||||
string s_prefix = nickname + "_"
|
||||
string s_int = s_prefix + "i"
|
||||
else
|
||||
s_prefix = ""
|
||||
s_int = "values"
|
||||
endif
|
||||
dfref savedf = getdatafolderdfr()
|
||||
string s_prefix = ""
|
||||
string s_int = "values"
|
||||
dfref df = find_hemi_data(nickname, s_prefix, s_int)
|
||||
|
||||
string s_totals = s_prefix + "tot"
|
||||
string s_weights = s_prefix + "wt"
|
||||
string s_polar = s_prefix + "pol"
|
||||
@ -2893,15 +2880,15 @@ function /wave hemi_azi_cut(nickname, pol)
|
||||
string s_cut
|
||||
sprintf s_cut, "%s_pol%03u", s_int, round(pol)
|
||||
|
||||
wave w_polar = $s_polar
|
||||
wave w_azim = $s_azim
|
||||
wave w_values = $s_int
|
||||
wave w_totals = $s_totals
|
||||
wave w_weights = $s_weights
|
||||
wave w_index = $s_index
|
||||
wave w_theta = $s_theta
|
||||
wave w_dphi = $s_dphi
|
||||
wave w_nphis = $s_nphis
|
||||
wave /sdfr=df w_polar = $s_polar
|
||||
wave /sdfr=df w_azim = $s_azim
|
||||
wave /sdfr=df w_values = $s_int
|
||||
wave /sdfr=df w_totals = $s_totals
|
||||
wave /sdfr=df w_weights = $s_weights
|
||||
wave /sdfr=df w_index = $s_index
|
||||
wave /sdfr=df w_theta = $s_theta
|
||||
wave /sdfr=df w_dphi = $s_dphi
|
||||
wave /sdfr=df w_nphis = $s_nphis
|
||||
|
||||
variable pol_st = abs(w_theta[1] - w_theta[0])
|
||||
variable pol1, pol2
|
||||
@ -2912,14 +2899,18 @@ function /wave hemi_azi_cut(nickname, pol)
|
||||
extract /free /indx w_polar, sel, (pol1 < w_polar) && (w_polar <= pol2)
|
||||
nsel = numpnts(sel)
|
||||
if (nsel > 0)
|
||||
setdatafolder df
|
||||
make /n=(nsel) /o $s_cut
|
||||
wave w_cut = $s_cut
|
||||
w_cut = w_values[sel]
|
||||
setscale /i x w_azim[sel[0]], w_azim[sel[nsel-1]], "<22>", w_cut
|
||||
setdatafolder savedf
|
||||
return w_cut
|
||||
else
|
||||
setdatafolder savedf
|
||||
return $""
|
||||
endif
|
||||
setdatafolder savedf
|
||||
end
|
||||
|
||||
static function check_contrast(values, pcmin, pcmax, vmin, vmax)
|
||||
|
Reference in New Issue
Block a user