Mathematica, combine ContourPlot3D and ListPointPlot3D - function

I would like to combine a 3-dimensional function plot with some 3D Points. Some lines that work separately are:
D3Plot= ContourPlot3D[x^2+y^2+z^2== 2, {x, 0, 2}, {y, 0, 2}, {z, 0,2}, ColorFunction -> Function[{x, y, z}, Hue[1*(1 - z)]]]
and:
atest3D = {{1, 1, 1}, {2, 1, 1}, {1, 2, 1}, {1, 1, 2}, {2, 2, 2}};
However, I get some problems when combining them together:
Show[atest3D,D3Plot,AxesOrigin -> {0, 0, 0}, PlotRange -> {{0, 3}, {0, 3}, {0, 3}}]
Is there any way to get this to work or some other way to show these two plots together?

Something like this?
Show[D3Plot, Graphics3D[{Red, PointSize[0.1], Point[atest3D]}], PlotRange -> All]

Is there also any way to make the points always viewable, also if they are on the other side of the surface?

Related

How to explode/unwrap all documents using jq?

I have a very large file that looks like this:
[
{a: 4, b: [1,2,3]},
{a: 6, b: [7,8,9]},
]
and I would like to transform it to
{a: 4, b: 1},
{a: 4, b: 2},
{a: 4, b: 3},
{a: 6, b: 7},
{a: 6, b: 8},
{a: 6, b: 9}
using jq. The filter .[] | {a: .a, b: .b[]} would work for a smaller set of input. Given the size of the file, I want to use --streaming. Anyone who could give a pointer on how to use streaming to solve this problem?
If the "very large file" fits into your memory, just decompose the array .[], and create your objects as needed using iterations {a, b: .b[]}:
jq -c '.[] | {a, b: .b[]}'
{"a":4,"b":1}
{"a":4,"b":2}
{"a":4,"b":3}
{"a":6,"b":7}
{"a":6,"b":8}
{"a":6,"b":9}
Demo
If not, but an array item alone would, use the --stream flag to read the file in parts, only consider the items level using truncate_stream with level 1, re-compose the array items using fromstream, and create the final objects as above:
jq --stream -cn 'fromstream(1 | truncate_stream(inputs)) | {a, b: .b[]}'
{"a":4,"b":1}
{"a":4,"b":2}
{"a":4,"b":3}
{"a":6,"b":7}
{"a":6,"b":8}
{"a":6,"b":9}

jq produces memory overflow

I have a json file where a time series in stored under data key and and an object id is in info key:
{info:
{id: abc},
data:[
[10, 5, 3],
[12, 6, 4],
# 5000 list items
]
}
I would like to flatten the json and produce something similar to:
[
{id: abc, time: 10, x: 5, y: 3},
{id: abc, time: 12, x: 6, y: 4},
# the rest of 5000 points
]
I'm running a jq query and seems to work well to produce a series of items:
"{time: .data[][0], x: .data[][2], y: .data[][1], item: .info.id}"
When I try to put the same expression into a list to create a list of dicts, I'm hitting a memory overflow limit:
"[{time: .data[][0], x: .data[][2], y: .data[][1], item: .info.id}]"
Is there anyhting else I can do differently? Many thanks in advance.
#peak has already pointed out the problem with your query, and here is the solution based on the insight he provided:
[ (.data[] | {time: .[0], x: .[1], y: .[2]}) + {id: .info.id} ]
See it online on jqplay.org

set_layout settings in Sublime Text 3

I just changed my OS from W10 to a Linux distro. I installed Sublime Text 3 and started to configure everything as I had in my other OS so I could start programming. Right now I am trying to include some custom layouts but I'm having a problem.
This is a layout I wanted to make:
So I wrote this:
{
"keys": ["alt+shift+5"],
"command": "set_layout",
"args":
{
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.33, 0.5, 0.66, 1.0],
"cells": [
[0, 0, 2, 1],
[2, 0, 4, 1],
[0, 1, 1, 2],
[1, 1, 3, 2],
[3, 1, 4, 2]
]
}
}
But this is not working for me right now.
Trying to apply that layout generates an error message in the Sublime console (View > Show Console):
invalid cell: (2,0 4,1)
That sort of catches me by surprise because generally the set_layout command takes what you give it without doing any error checking, which can get you into sticky situations like weird rendering errors or putting panes outside of the visible area of the window.
In any case, modifying the layout to something like the following solves the problem, which re-orders the cell layouts.
{
"cols":[0.0, 0.5, 1.0],
"rows":[0.0, 0.33, 0.5, 0.67, 1.0 ,
"cells":[
[0, 0, 1, 2],
[1, 0, 2, 1],
[0, 2, 1, 4],
[1, 1, 2, 3],
[1, 3, 2, 4]
]
}

Looping through all json elements using Unity Boomlagoon Json

I'm using Boomlagoon Json in my Unity project. My Json file has several lines in it, and so far I can only get Boomlagoon to read the first one only. Is there a way I can make a loop where it will go through all parse the entire json file?
Here is my json:
{"type": 1, "squads": [{"player_id": 1, "squad": [1, 2, 3, 4]}, {"player_id": 2, "squad": [6, 7, 8, 9]}], "room_number": 1, "alliance_id": 1, "level": 1}
{"type": 2, "squads": [{"player_id": 2, "squad": [1, 2, 3, 4]}, {"player_id": 3, "squad": [6, 7, 8, 9]}], "room_number": 2, "alliance_id": 1, "level": 1}
{"type": 3, "squads": [{"player_id": 3, "squad": [1, 2, 3, 4]}, {"player_id": 4, "squad": [6, 7, 8, 9]}], "room_number": 3, "alliance_id": 1, "level": 1}
And when I do a loop like this:
foreach (KeyValuePair<string, JSONValue> pair in emptyObject) { ... }
it only gives me results for the first entry (in this example type:1). Thanks.
Your file actually contains 3 JSON objects, and what happens when you parse it is that the parsing stops once the first object ends. You need to parse each line separately to get all of the data.
As an aside, you'll notice that if you paste your JSON into the validator at jsonlint.com it'll give you a parsing error where the second object begins.

Custom layouts, Sublime text 2

I've been working with a 2 column system so far but feel I'm needing a third and that 3 spread across the screen doesn't give much of a view without adjusting the width every time.
It's there a way to get the grid layout but have the bottom half of the screen one file.
I know it's a long shot but wondering if anyone knows of anything
Found that you can edit for custom layouts in Packages/default/Main.sublime-menu
Having problems saving though error in trying to parse file: expected value in ~/library/application support/sublime text 2/packages/default/Main.sublime-menu:407:21
Edited: for better layout
Found something that is similar, been trying to mod it but don't understand how the cells work
This one is similar
"args":
{
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells": [
[0, 0, 1, 2], // (0.0, 0.0) -> (0.5, 1.0)
[1, 0, 2, 1], // (0.5, 0.0) -> (1.0, 0.5)
[1, 1, 2, 2] // (0.5, 0.5) -> (1.0, 1.0)
]
}
which gives
Assuming these are just coordinates with 0,0 at the upper left, something like this should work:
[0, 0, 1, 1],
[1, 0, 2, 1],
[0, 1, 2, 2]
Edit: Just tested, and it does.
Create the file Main.sublime-menu in your Packages > User folder (best to leave the default menu alone) and put the following code in it:
[{
"id": "view",
"children": [{
"id": "layout",
"children": [{
"command": "set_layout",
"caption" : "Custom: 3 Pane",
"mnemonic": "C",
"args": {
"cols": [0.0, 0.5, 1.0],
"rows": [0.0, 0.5, 1.0],
"cells": [
[0, 0, 1, 1],
[1, 0, 2, 1],
[0, 1, 2, 2]
]
}
}]
}]
}]
You will see Custom: 3 Pane in your layout options. No need to restart Sublime Text.
For anyone interested, here is a gist containing this layout as well as a flipped version.
This was very helpful for visualizing what points the coordinates are referring to: http://www.sublimetext.com/forum/viewtopic.php?f=6&t=7284&start=0&hilit=set+layout