Based on the ImageView.imshow documentation here:
https://github.com/JuliaImages/ImageView.jl
it looks like it should be possible to change the zoom rectangle of an imshow viewer programmatically, however I have not been able to find a concrete example of how to do this and I'm not sure how to create an object of the correct type to send to the signal.
If I do this:
guidict = imshow( videog )
zr = guidict["roi"]["zoomregion"]
zr
I get:
10: "input-21" = ZoomRegion{RInt64}(XY(1..640, 1..480), XY(1..640, 1..480)) ZoomRegion{RInt64}
Aside from the complexity of the types, I don't understand why the zoom region should need to be specified twice as it is here.
In any case if I do:
push!( zr, ZoomRegion{RInt64}( XY(200..280, 280..360), XY(200:280, 280..360) ) )
(where I'm trying to set the zoom to 200:280 in X and 280:360 in Y)
I get the following error:
ERROR: promotion of types UnitRange{Int64} and IntervalSets.Interval{:closed,:closed,Int64} failed to change any arguments
Stacktrace:
[1] error(::String, ::String, ::String) at ./error.jl:42
[2] sametype_error(::Tuple{UnitRange{Int64},IntervalSets.Interval{:closed,:closed,Int64}}) at ./promotion.jl:308
[3] not_sametype(::Tuple{UnitRange{Int64},IntervalSets.Interval{:closed,:closed,Int64}}, ::Tuple{UnitRange{Int64},IntervalSets.Interval{:closed,:closed,Int64}}) at ./promotion.jl:302
[4] promote at ./promotion.jl:285 [inlined]
[5] XY(::UnitRange{Int64}, ::IntervalSets.Interval{:closed,:closed,Int64}) at /home/flynn/.julia/packages/GtkReactive/2h7NX/src/graphics_interaction.jl:93
[6] top-level scope at none:0
Does anyone have a concrete example of how to do this ?
The zoom region is made of two components, full view and current view. When you're pushing to the signal you are only moving the current view [which handles the zooming].
You can use unit ranges when pushing, like this
push!(zr, (200:280, 280:360))
To reset back to the full view you just need to then do this
push!(zr, zr.value.fullview)
Related
I've just noticed that R mark down always generates the same numbers when I begin with loading work space. For instance I type something like
load("C:/Users/Piotr/Documents/MyWorkSpace.RData")
rnorm(10,0,1)
and the result is always the same. In my instance this is
[1] 1.2741648 -0.7905977 -0.4062481 0.3983397 0.3917316 -1.4122062
[7] 0.6595976 0.5776770 -1.0952124 0.1878156
Can you explain it to me and tell my how can I deal with it? ;/
The Random Number Generator stores its current state in an hidden variable called .Random.seed.
When you load MyWorkspace.RData, you restore the state of RNG.
To reset the Random Number Generator, just delete .Random.seed
rm(.Random.seed, envir=globalenv())
(First Question so apologies)
Bokeh 1.3.4
Situation:
I am trying top map a Bokeh MultiLine using a CDSView and all the existing examples seem to use the "figure" object which has a helper (multi_line) which accepts a view as an argument. I am doing this on top of a GMAPPlot which does not support multi_line (only MultiLine) (see below). The commented out line throws an error saying GMAPPlot does not support multi_line.
plot = GMapPlot(
x_range=Range1d(), y_range=Range1d(), map_options=map_options, sizing_mode='scale_height'
)
.
.
.
sel_sa1s = []
v_bf = [True if sa1_val in sel_sa1s else False for sa1_val in v_source.data['SA1']]
v_view = CDSView(source=v_source, filters=[BooleanFilter(v_bf)])
v_ml = MultiLine(xs="xs",ys="ys",line_color="black", line_width="w")
#v_rend = plot.multi_line(xs="xs",ys="ys",line_color="black", line_width="w", source=v_source, view=v_view)
v_rend = plot.add_glyph(v_source, v_ml, name='votes')
The snippet shown above works and maps the entire network (very crowded) because there is no filter. What I want to have happen is for the filter to be initialised to hide everything then when the user clicks on an area (SA1) it will display the network related to that SA1.
Actually I can do that but only one area at a time and it would be much more efficient to be able to load the whole map and use a filtered view to control which sub-networks are displayed.
It seems that GMAPPlot only likes the pattern:
create glyph
add glyph
So, my question is - how does one use a CDSView in this environment (how does one add it to the renderer?)
Screenshot of unfiltered data set
It seems that GMAPPlot only likes the pattern:
create glyph
add glyph
That has not been true for some time. There is a higher level bokeh.plotting.gmap function that creates and configures GMapPlot instances with deafult axes, etc, and also has all the same methods and conveniences as figure (e.g. multi_line). It will be much less work to go this route than assembling everything by hand from low-level objects.
This should be trivial but I can't for the life of me figure out how to do this: I am trying to read an attribute value from a NetCDF4 file in R. Now, my NetCDF4 file (uploaded here) is fairly complex, i.e. it contains nested groups.
I would like to extract the value of the attribute called gml:posList from the group METADATA/EOP_METADATA/om:featureOfInterest/eop:multiExtentOf/gml:surfaceMembers/gml:exterior using R. I am not sure if it matters in this context, but this group does not contain any variables, only metadata attributes.
I have tried the following
library(ncdf4)
fid = nc_open('S5P_NRTI_L2__NO2____20180728T130136_20180728T130636_04089_01_010100_20180728T140302.nc')
ncatt_get(fid, varid=0, attname='METADATA/EOP_METADATA/om:featureOfInterest/eop:multiExtentOf/gml:surfaceMembers/gml:exterior/gml:posList', verbose=TRUE)
but this returns
[1] "ncatt_get: entering"
[1] "ncatt_get: is a global att"
[1] "ncatt_get: calling ncatt_get_inner for a global att"
[1] "ncatt_get_inner: entering with ncid= 65536 varid= -1 attname= METADATA/EOP_METADATA/om:featureOfInterest/eop:multiExtentOf/gml:surfaceMembers/gml:exterior/gml:posList"
[1] "ncatt_get_inner: about to call R_nc4_inq_att"
[1] "ncatt_get_inner: R_nc4_inq_att returned with error= -43 type= -1"
$`hasatt`
[1] FALSE
$value
[1] 0
presumably indicating that it cannot find the attribute and I assume that I got the path wrong somehow.
So my question is, how do I need to specify the path to an attribute that is a) in a nested group and b) not linked to a specific variable, such that ncatt_get() can find the attribute and return its value?
By the way, just for reference, in Matlab the command
test = ncreadatt(file, 'METADATA/EOP_METADATA/om:featureOfInterest/eop:multiExtentOf/gml:surfaceMembers/gml:exterior', 'gml:posList')
works fine, so I know it's not an issue with the file.
Any hints would be highly appreciated!
I'm facing a problem described as follows :
Example :
Giving a path :
[0]------[1]------[2]------[3]------[4]
give the minimum dominatig set of this path : the solution would be [1] and [3]
The path in my program is described as an Adjacency list ,so :
[0]--> [1]
[1]--> [0];[2]
[2]--> [1];3]
[3]--> [2];4]
[4]--> [3]
What would be the idea to get the list of those elements from the Adjacency list?
I frequently use user defined functions in my code.
RStudio supports the automatic completion of code using the Tab key. I find this amazing because I always can read quickly what is supposed to go in the (...) of functions/calls.
However, my user defined functions just show the parameters, no additional info and obviously, no help page.
This isn't so much pain for me but I would like to share code I think it would be useful to have some information at hand besides the #coments in every line.
Nowadays, when I share, my lines usually look like this
myfun <- function(x1,x2,x3,...){
# This is a function for this and that
# x1 is a factor, x2 is an integer ...
# This line of code is useful for transformation of x2 by x1
some code here
# Now we do this other thing
more code
# This is where the magic happens
return (magic)
}
I think this line by line comment is great but I'd like to improve it and make some things handy just like every other function.
Not really an answer, but if you are interested in exploring this further, you should start at the rcompgen-help page (although that's not a function name) and also examine the code of:
rc.settings
Also, executing this allows you to see what the .CompletionEnv has in it for currently loaded packages:
names(rc.status())
#-----
[1] "attached_packages" "comps" "linebuffer" "start"
[5] "options" "help_topics" "isFirstArg" "fileName"
[9] "end" "token" "fguess" "settings"
And if you just look at:
rc.status()$help_topics
... you see the character items that the tab-completion mechanism uses for matching. On my machine at the moment there are 8881 items in that vector.