Export datas from mongodb using mongoexport from a specific time range with query and timestamp - mongoexport

I'm trying to export a collection from mongodb using mongoexport. This works so far:
mongoexport.exe --db dataloggin --collection p1 --out myRecords.json
The problem is that the file is huge and I can not open it anymore (araound 20GB, 30 days, every half a second a document).
I just need the data between the 3. March and the 5 March, so I tried to select this date range with the query selector as following:
mongoexport.exe --db dataloggin --collection p1 -q='{"timestamp":{"$gte":{"$timestamp":"2016-03-3T00:00:00.000Z"}:},"timestamp":{"$lt":{"$timestamp":"2016-03-05T00:00:00.000Z"}}}' --out myRecords.json
But I get an error:
error validating settings: query '[39 123 116 105 109 101 115 116 97 109 112 58 123 36 103 116 101 58 123 36 116 105 109 101 115 116 97 109 112 58 50 48 49 54 45 48 49 45 48 49 84 48 48 58 48 48 58 48 48 46 48 48 48 90 125 58 125 44 116 105 109 101 115 116 97 109 112 58 123 36 108 116 58 123 36 116 105 109 101 115 116 97 109 112 58 50 48 49 54 45 48 49 45 48 49 84 48 48 58 48 48 58 48 48 46 48 48 48 90 125 125 125 39]' is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface {}
Someone have an idea?
Many Thanks and regards

Related

SVG stroke gradient causes horizontal lines to display on iOS Safari

Adding a radial gradient to my SVG path seems to cause weird horizontal (anti-aliasing?) lines on some iOS devices or when you zoom in/out on an iOS device. I wasn't able to replicate it anywhere else.
Here's the (isolated) code:
<svg class="componentClass__chart-svg" width="335" height="318" viewBox="0 0 335 320" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="axesGradient" cx="50%" cy="0%" fx="50%" fy="0%" r="50%">
<stop stop-color="#FFFFFF" offset="10%"></stop>
<stop stop-color="#FFFFFF" offset="100%" stop-opacity="0.2"></stop>
</radialGradient>
</defs>
<path class="componentClass__axes" stroke-width="2" stroke="url(#axesGradient)" fill="none" d="M151 12 Q167 0 183 12 L319 108 Q335 120 329 139 L276 299 Q270 318 250 318 L85 318 Q65 318 59 299 L6 139 Q0 120 16 108 Z
M151 37 Q167 25 183 37 L293 116 Q309 128 303 147 L260 275 Q254 294 234 294 L101 294 Q81 294 75 275 L32 147 Q26 128 42 116 Z
M151 62 Q167 50 183 62 L267 124 Q283 136 277 155 L244 251 Q238 270 218 270 L117 270 Q97 270 91 251 L58 155 Q52 136 68 124 Z
M151 87 Q167 75 183 87 L241 132 Q257 144 251 163 L228 227 Q222 246 202 246 L133 246 Q113 246 107 227 L84 163 Q78 144 94 132 Z
M152 113 Q167 100 183 113 L215 139 Q231 152 224 171 L213 203 Q206 222 186 222 L149 222 Q129 222 122 203 L111 171 Q104 152 119 139 Z
" />
</svg>
And the issue:
SVG showing horizontal line
Note this doesn't happen on every iPhone or iPad, but you're usually able to replicate it when you try zooming in and out.
I was able to nail down the issue to this particular use case: as soon as you add the gradient to the stroke, it starts happening. If you change stroke="url(#axesGradient) to just stroke="#FFF", it doesn't seem to happen.
Is there any way I can optimize the SVG to prevent rendering issues?
Here's a Codepen with the exact code above.
Had the same problem, but in my case these lines appeared in any browser on IOS 16, updating to IOS 16.3 fixed it

How to overcome with this error when using Networkx's kernighan_lin_bisection

I want to use kernighan_lin_bisection from Networkx to separate a network data.
But the error below showed up and I'm stuck.
It would be highly appreciated if you could help me overcome this error.
QT-------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in ()
17 for c in init_partition:
18 for n in c:
---> 19 color_map_i[n]=colors[counter]
20 counter=counter+1
21
IndexError: list assignment index out of range
UNQT---------------------------------------------------------------------------
The coding I used and data source"200224_04_act.prn" are below.
QT---------------------------------------------------
G=nx.read_edgelist("200224_04_act.prn",nodetype=int)
colors=["red","blue","green"]
pos=nx.spring_layout(G)
init_nodes=np.array_split(G.nodes(),2)
init_partition=[set(init_nodes[0]),set(init_nodes[1])]
print(init_partition)
from networkx.algorithms.community import kernighan_lin_bisection
color_map_i=["black"]*nx.number_of_nodes(G)
print(color_map_i)
counter=0
for c in init_partition:
for n in c:
color_map_i[n]=colors[counter]
counter=counter+1
print(color_map_i)
nx.draw_networkx_edges(G,pos)
nx.draw_networkx_nodes(G,pos,node_color=color_map_i)
nx.draw_networkx_labels(G,pos)
plt.axis("off")
plt.show()
lst_b=kernighan_lin_bisection(G,partition=init_partition)
color_map_b=["black"]*nx.number_of_nodes(G)
counter=0
for c in lst_b:
for n in c:
color_map_b[n]=colors[counter]
counter=counter+1
nx.draw_networkx_edges(G,pos)
nx.draw_networkx_nodes(G,pos,node_color=color_map_b)
nx.draw_networkx_labels(G,pos)
plt.axis("off")
plt.show()
UNQT--------------------------------------------------------------
"200224_04_act.prn" below.(Number of nodes is around 2000 but I made it
small due to the limit of number of character)
1 415
2 415
3 415
3 1350
4 1351
5 1352
6 383
7 993
8 1353
9 887
10 887
11 887
12 887
13 887
14 1185
15 1185
16 1185
17 1185
18 1185
19 1146
20 1146
21 1146
22 1146
21 776
23 776
24 707
25 707
26 707
27 707
28 707
29 754
21 754
30 754
31 754
32 754
33 778
34 778
35 778
36 778
37 778
38 859
39 859
40 1354
41 563
42 563
43 563
44 563
45 563
46 1209
47 1209
48 1209
49 1209
50 1209
51 715
52 715
53 715
54 715
55 715
56 1048
57 1048
58 1047
59 1047
60 1047
61 1047
62 1047
63 718
64 718
65 718
66 718
67 718
68 947
17 947
69 947
70 889
71 744
72 744
73 744
74 744
75 744
76 1137
77 1137
78 1137
79 1137
80 612
81 612
82 612
83 612
17 612
84 790
85 790
86 790
87 790
88 790
89 922
90 922
91 922
92 922
93 922
21 738
94 738
95 738
96 738
97 738
98 1355
81 807
99 807
17 807
100 725
101 725
17 725
102 725
103 725
23 1046
104 661
105 661
106 661
107 661
108 661
109 907
110 907
111 907
112 907
113 907
114 840
115 840
116 840
117 840
17 840
118 759
23 759
119 759
23 761
120 761
121 761
122 761
123 1356
124 1265
125 1265
126 1265
127 1265
128 1265
129 894
29 894
130 894
131 894
132 667
133 667
124 758
134 758
135 758
122 758
136 758
137 471
138 471
You've got
for c in init_partition:
for n in c:
color_map_i[n]=colors[counter]
counter=counter+1
It looks to me like n will loop over all of the nodes of the graph. I do not see any entries in the graph that are 0. So probably the nodes are numbered 1 to N, while color_map_i is indexed from 0 to N-1. So it would break when n=N.
A good way to hunt for bugs like this in general would be to print n right before the line giving the error. This would give a hint to what the problem is.

Why does calcHist in Opencv produce 0 array in output?

I do hist calculation using OpenCV. I have the following implementation.
//Check image
for (int i = 0; i < block.rows; i++)
{
unsigned char *ptr = block.ptr<unsigned char>(i);
for (int j = 0; j < block.cols; j++)
{
cout << (int)ptr[j] << " ";
}
cout << endl;
}
//That gave
240 130 176 129 96 122 192 127 240 123 112 122 64 121 80 118 128 129 224 119
160 138 176 132 144 128 144 132 64 128 64 126 16 128 16 129 112 126 64 127
128 128 96 133 240 124 240 132 96 126 32 124 144 128 144 129 176 128 144 124
0 136 112 136 80 131 64 131 16 132 48 131 0 128 224 129 240 126 144 129
16 132 240 138 160 132 64 134 16 131 112 129 208 126 0 128 16 126 176 122
208 139 176 133 176 135 240 138 176 136 80 131 128 133 192 132 64 129 144 132
32 136 176 138 224 139 224 136 80 127 160 135 144 132 64 131 192 131 48 126
80 144 192 138 16 136 192 138 240 135 112 135 32 133 208 132 32 130 64 130
144 141 144 135 48 139 32 135 32 134 112 134 80 130 160 126 144 131 96 128
80 144 208 139 112 141 16 137 96 138 48 134 0 136 96 137 32 135 192 130
208 143 224 140 64 140 240 132 224 132 96 133 160 133 96 134 0 129 96 131
128 148 144 140 128 139 96 139 32 136 48 135 80 132 96 137 0 133 240 140
208 136 96 144 64 137 144 135 16 135 16 132 0 134 160 136 128 134 128 132
240 147 176 144 160 138 176 144 176 139 160 143 224 135 128 137 96 139 160 136
176 139 144 133 240 142 192 139 112 133 112 135 208 131 208 132 128 135 48 133
32 150 0 144 128 139 0 141 64 142 32 136 16 137 112 136 16 137 48 133
128 143 0 141 48 141 192 135 128 144 16 138 80 136 192 134 16 134 160 131
0 144 144 148 16 143 48 136 144 140 144 138 160 136 192 137 80 138 160 136
16 142 32 141 192 140 160 135 32 136 192 135 192 135 240 135 48 138 0 143
208 142 96 149 160 146 208 146 32 138 192 141 112 136 208 138 96 142 160 137
128 145 64 142 16 136 0 137 144 132 32 136 96 138 48 136 240 131 208 130
48 142 128 143 128 143 160 149 208 140 16 142 176 137 208 136 240 138 0 143
192 146 160 141 112 144 96 143 112 135 224 140 96 135 176 135 80 135 128 135
48 144 224 147 0 139 48 139 128 142 224 143 0 144 80 140 16 139 192 140
0 146 160 143 176 138 160 146 240 135 128 136 176 137 192 134 192 136 112 136
208 147 16 143 80 149 112 146 224 134 16 145 48 141 224 138 128 137 112 135
64 146 0 140 192 140 0 143 208 140 96 138 128 137 176 138 208 138 48 135
64 148 224 142 16 140 64 143 112 137 64 141 64 143 224 135 80 138 80 138
240 143 240 142 64 145 0 142 208 142 128 139 0 136 240 141 48 138 80 137
64 147 32 148 112 145 80 140 64 143 112 144 0 139 112 137 176 136 80 143
48 148 64 146 144 142 160 139 176 140 0 140 144 139 32 138 80 137 112 139
208 145 192 145 96 148 240 145 128 139 16 141 80 142 224 137 16 144 208 140
240 142 96 139 176 148 16 139 96 143 16 141 32 139 176 141 48 134 192 141
128 147 64 145 80 150 112 140 112 143 240 142 96 143 224 139 192 143 144 137
0 148 80 145 128 142 48 146 160 140 32 141 192 139 16 136 176 138 16 143
48 149 80 143 80 144 112 144 64 144 208 143 96 142 192 142 240 138 48 138
192 143 48 149 176 145 176 142 64 142 160 139 16 138 128 139 64 139 192 138
192 147 224 144 64 143 64 148 0 144 96 143 32 147 208 142 64 141 224 137
112 146 208 144 96 141 64 142 208 141 112 138 144 138 80 135 16 140 176 140
208 146 96 144 112 148 112 146 112 147 192 148 16 141 32 143 224 137 80 140
128 149 96 146 224 144 32 141 240 144 112 136 192 141 64 139 96 135 144 138
160 144 80 149 208 146 96 145 128 142 64 142 64 147 208 141 144 141 16 141
48 145 192 145 32 140 176 142 0 143 96 136 160 139 80 136 192 138 96 138
32 151 224 152 208 143 112 142 0 142 144 145 176 145 0 139 240 141 32 139
112 142 0 139 176 136 64 140 128 140 64 135 64 139 128 140 64 137 96 138
128 150 0 153 32 146 208 140 80 149 240 141 240 136 224 140 160 140 32 146
240 141 160 142 192 144 208 138 112 141 144 138 128 138 48 135 176 140 16 135
96 150 176 148 80 142 224 142 16 148 208 140 240 136 224 141 32 140 144 137
192 139 0 144 64 142 144 143 32 139 192 138 160 139 208 137 80 140 96 134
48 148 192 146 16 149 0 141 144 137 32 140 192 142 176 138 240 140 16 138
80 146 144 142 80 143 192 137 224 141 176 140 80 139 128 138 64 135 144 134
160 146 208 143 160 143 0 145 112 140 224 144 208 142 80 144 0 138 144 142
144 143 48 139 32 141 0 147 16 140 0 143 176 140 128 133 176 139 160 134
176 150 240 145 64 146 144 142 96 138 240 141 128 141 112 140 128 137 160 135
176 140 128 139 224 144 160 138 208 138 224 135 48 139 208 132 160 137 96 134
208 143 112 148 0 141 96 143 96 136 32 143 176 138 240 139 160 141 176 141
176 148 176 142 112 140 16 143 96 136 80 139 240 139 144 138 160 139 160 137
96 145 32 151 224 142 96 143 48 143 96 141 112 135 48 141 240 136 80 138
80 145 0 140 64 141 48 144 32 141 208 137 80 136 192 134 32 135 16 137
64 147 48 148 240 143 208 139 112 140 240 138 176 141 32 144 64 138 64 139
160 142 208 141 160 142 48 140 208 138 80 136 160 137 48 141 224 137 96 134
64 149 48 147 32 142 80 148 176 142 192 142 208 138 48 139 112 136 64 139
144 144 96 143 240 140 240 138 160 140 0 140 0 135 208 133 32 134 192 132
80 143 0 145 128 140 48 143 208 141 96 143 96 139 192 138 0 139 112 140
96 144 80 140 64 144 32 141 192 137 32 138 176 137 80 137 80 138 0 136
64 147 144 145 208 140 64 138 144 145 224 137 48 140 0 140 96 139 192 134
64 141 208 143 128 144 80 135 192 135 112 139 176 135 128 139 144 135 128 134
80 145 32 146 80 142 64 143 192 143 176 140 224 142 112 141 32 139 144 141
96 141 64 141 240 143 224 136 48 142 160 132 192 136 160 136 64 137 32 134
224 147 192 144 96 145 16 140 192 142 128 138 0 141 0 145 176 136 96 140
128 146 16 143 160 139 176 141 192 138 208 137 48 141 160 129 96 137 144 134
112 145 32 146 208 135 240 139 240 137 192 142 176 132 96 138 144 131 16 140
64 143 112 141 112 142 0 140 160 141 0 135 240 136 224 141 112 137 64 134
160 144 80 143 160 145 192 141 96 135 80 140 240 134 224 138 48 137 176 137
64 140 80 138 0 138 64 136 48 136 128 133 16 133 224 132 80 135 224 133
224 142 16 146 80 145 224 137 144 138 160 138 160 132 64 137 112 133 0 135
224 140 80 141 0 138 112 135 0 132 144 136 240 131 112 137 208 133 0 135
16 143 32 139 32 142 160 138 96 133 128 136 112 132 16 136 176 133 112 136
96 141 0 138 96 133 176 136 112 133 176 136 240 126 0 131 16 127 80 130
112 142 160 138 0 136 16 140 192 132 48 138 64 136 176 135 208 130 160 140
So pixel values are there.
//Histogram calculation
int histbin = 128;//quantize
int histSize[] = { histbin };
float range[] = { 0, 255 };
const float *ranges[] = { range };
Mat hist;
int channels[] = { 0};
calcHist(&block, 1, channels, Mat(), hist, 1, histSize, ranges, true, false);
//Print output
for (int h = 0; h < histbin; h++)
{
float binVal = hist.at<float>(h);
cout << " " << binVal;
}
I have outputs as follow.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
What is wrong with my implementation?

parsing using awk

how to parse a file based on data from another file using awk.
i made a script:
BEGIN{ FS="\t" ; OFS="\t"
while((getline<"headfpkm")>0) {
++a
id[a]=$1
fpkm[a]=$2
print id[a],fpkm[a]
}
lastid=id[a]
print lastid
close("headfpkm")
}
/$lastid/{
print $2,$3,$5,$7,$8,$14,fpkm[a]
a--
lastid=id[a]
}
END{ print "total lines=",FNR,"\n\nfile 1 index: ",a}
when i run it :
/$ awk -f testawk.awk file2
it runs the BEGIN section properly but doesnt give any output.
NM_000014 5.04503
NM_000015 0.586677
NM_000016 1.138332278
NM_000017 0.64386
NM_000018 3.61746
NM_000019 2.8793
NM_000020 10.846
NM_000021 0.685098
NM_000022 46388.6
NM_000026 0.257471
NM_000026
total lines= 10
file 1 index: 10
Is anything wrong with the searching section??
file 2 looks like this:
34 ACADM NM_000016 9606 hsa-miR-3148 3 80 87 0.003 -0.016 -0.094 0.082 0.112 -0.160 97
34 ACADM NM_000016 9606 hsa-miR-3163 1 623 629 0.001 -0.022 -0.020 0.065 0.125 -0.01 57
35 ACADS NM_000017 9606 hsa-miR-3921 3 68 75 0.013 0.192 -0.097 0.031 -0.039 -0.147 82
35 ACADS NM_000017 9606 hsa-miR-4303 2 67 73 0.012 0.150 -0.052 0.013 -0.039 -0.036 31
35 ACADS NM_000017 9606 hsa-miR-4653-5p 3 68 75 0.003 0.192 -0.097 0.031 -0.039 -0.157 84
37 ACADVL NM_000018 9606 hsa-miR-124 2 31 37 0.003 0.023 -0.057 0.012 -0.032 -0.171 76
37 ACADVL NM_000018 9606 hsa-miR-1827 2 135 141 -0.007 -0.043 -0.058 0.039 -0.069 -0.258 91
37 ACADVL NM_000018 9606 hsa-miR-2682 2 134 140 0.003 -0.014 -0.058 0.004 -0.047 -0.232 87
37 ACADVL NM_000018 9606 hsa-miR-449c 2 134 140 -0.035 -0.014 -0.058 0.004 -0.047 -0.270 92
37 ACADVL NM_000018 9606 hsa-miR-506 2 31 37 -0.016 0.023 -0.057 0.012 -0.032 -0.190 80
This is going to be a bit of guess, because I'm not 100% sure as to what you're trying to accomplish. The better way to solve your problem, would be to do something like this:
BEGIN {
FS=OFS="\t"
}
FNR==NR {
c++
a[$1]=$2
next
}
$3 in a {
print $2,$3,$5,$7,$8,$14,a[$3]
}
END {
printf "total lines=%s\n\nfile 1 index: %s\n", FNR, c
}
Run like:
awk -f script.awk headfpkm file2
Results:
ACADM NM_000016 hsa-miR-3148 80 87 -0.160 1.138332278
ACADM NM_000016 hsa-miR-3163 623 629 -0.01 1.138332278
ACADS NM_000017 hsa-miR-3921 68 75 -0.147 0.64386
ACADS NM_000017 hsa-miR-4303 67 73 -0.036 0.64386
ACADS NM_000017 hsa-miR-4653-5p 68 75 -0.157 0.64386
ACADVL NM_000018 hsa-miR-124 31 37 -0.171 3.61746
ACADVL NM_000018 hsa-miR-1827 135 141 -0.258 3.61746
ACADVL NM_000018 hsa-miR-2682 134 140 -0.232 3.61746
ACADVL NM_000018 hsa-miR-449c 134 140 -0.270 3.61746
ACADVL NM_000018 hsa-miR-506 31 37 -0.190 3.61746
total lines=10
file 1 index: 10

Convert PNG images to pixel gray-level values feature vectors

I am a newbie in MATLAB and I have a set of bmp images which I need to convert into pixel gray-level values as feature vectors of image. Can anyone suggest me the way how I can do that?
I need to use these pixel gray-level values as features and then perform operations like PCA/LDA.
I tried imread() but it returns me a matrix.. I feel feature vector will be just one row vector.
Regards,
imread() is the correct way to do it. Then just convert from a matrix into a vector. For example:
>> X = randi(255, 10)
X =
208 41 168 181 112 71 192 215 90 20
231 248 10 9 98 174 66 65 212 14
33 245 217 71 196 168 130 208 150 136
233 124 239 12 203 42 179 63 141 199
162 205 174 25 48 31 228 237 234 239
25 37 194 210 125 128 245 90 73 34
72 108 190 178 114 245 140 51 194 146
140 234 101 81 165 87 36 65 193 120
245 203 168 243 181 150 39 158 98 4
247 245 44 9 193 58 66 121 145 86
>> X(:)
ans =
208
231
33
233
162
25
72
140
245
247
...
Then you can just stack your different observations together with [] and do PCA.

Resources