SVG Spin Gear without Javascript - animation

I made a rusty gear in Inkscape. How can I make the gear spin like a rotating wheel without using Javascript. I want this SVG file to only contain SVG code. I can either manually program the SVG or use Inkscape to make the animation. Here is my code. The cog orbits some center, but I want it to spin in place.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="1200"
height="1200"
id="svg2">
<title
id="title2993">Gear</title>
<defs
id="defs4">
<filter
y="-0.2"
height="1.4"
color-interpolation-filters="sRGB"
id="filter3845">
<feTurbulence
baseFrequency="0.08"
type="fractalNoise"
seed="0"
numOctaves="5"
id="feTurbulence3847" />
<feGaussianBlur
result="result91"
stdDeviation="0.5"
id="feGaussianBlur3849" />
<feDisplacementMap
in2="result91"
scale="20"
xChannelSelector="R"
yChannelSelector="G"
in="SourceGraphic"
result="result1"
id="feDisplacementMap3851" />
<feComposite
in2="SourceGraphic"
operator="atop"
in="result1"
result="fbSourceGraphic"
id="feComposite3853" />
<feColorMatrix
id="feColorMatrix3889"
values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
in="fbSourceGraphic"
result="fbSourceGraphicAlpha" />
<feMorphology
in="fbSourceGraphic"
result="result8"
operator="dilate"
radius="7"
id="feMorphology3891" />
<feComposite
in2="result8"
operator="arithmetic"
k1="0.5"
k2="0"
k3="0.5"
k4="0"
in="fbSourceGraphic"
result="result10"
id="feComposite3893" />
<feTurbulence
baseFrequency="0.07"
numOctaves="3"
type="fractalNoise"
result="result11"
id="feTurbulence3895" />
<feDisplacementMap
in2="result11"
scale="10"
xChannelSelector="R"
yChannelSelector="A"
in="result10"
result="result12"
id="feDisplacementMap3897" />
<feComposite
in2="result12"
operator="arithmetic"
k1="0.25"
k2="0.25"
k3="0.75"
k4="0"
in="fbSourceGraphic"
result="fbSourceGraphic"
id="feComposite3899" />
<feColorMatrix
id="feColorMatrix3901"
values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
in="fbSourceGraphic"
result="fbSourceGraphicAlpha" />
<feGaussianBlur
stdDeviation="1"
in="fbSourceGraphic"
result="result0"
id="feGaussianBlur3903" />
<feTurbulence
result="result1"
numOctaves="4"
seed="4"
baseFrequency="0.057"
type="turbulence"
id="feTurbulence3905" />
<feDisplacementMap
in2="result1"
scale="0"
xChannelSelector="R"
yChannelSelector="A"
result="result91"
id="feDisplacementMap3907" />
<feComposite
in2="result91"
operator="out"
in="result0"
result="result2"
id="feComposite3909" />
<feComposite
in2="result2"
operator="arithmetic"
k1="0.1"
k2="0"
k3="1.2"
k4="0"
in="fbSourceGraphicAlpha"
result="result5"
id="feComposite3911" />
<feBlend
in2="result5"
mode="multiply"
result="fbSourceGraphic"
id="feBlend3913" />
<feGaussianBlur
result="result0"
in="fbSourceGraphic"
stdDeviation="3"
id="feGaussianBlur3915" />
<feSpecularLighting
specularExponent="15"
specularConstant="0.40000001"
surfaceScale="3"
lighting-color="#fee65d"
result="result1"
in="result0"
id="feSpecularLighting3917">
<fePointLight
z="20000"
y="-10000"
x="-5000"
id="fePointLight3919" />
</feSpecularLighting>
<feComposite
in2="fbSourceGraphic"
operator="in"
in="result1"
result="result2"
id="feComposite3921" />
<feComposite
in2="result2"
operator="arithmetic"
k1="-1"
k2="2.5"
k3="3.5"
k4="0"
in="fbSourceGraphic"
result="result4"
id="feComposite3923" />
<feBlend
in2="result4"
mode="multiply"
id="feBlend3925" />
</filter>
<filter
y="-0.2"
height="1.4"
color-interpolation-filters="sRGB"
id="filter3845-3">
<feTurbulence
baseFrequency="0.08"
type="fractalNoise"
seed="0"
numOctaves="5"
id="feTurbulence3847-3" />
<feGaussianBlur
result="result91"
stdDeviation="0.5"
id="feGaussianBlur3849-1" />
<feDisplacementMap
in2="result91"
scale="20"
xChannelSelector="R"
yChannelSelector="G"
in="SourceGraphic"
result="result1"
id="feDisplacementMap3851-7" />
<feComposite
in2="SourceGraphic"
operator="atop"
in="result1"
result="fbSourceGraphic"
id="feComposite3853-4" />
<feColorMatrix
id="feColorMatrix3889-9"
values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
in="fbSourceGraphic"
result="fbSourceGraphicAlpha" />
<feMorphology
in="fbSourceGraphic"
result="result8"
operator="dilate"
radius="7"
id="feMorphology3891-3" />
<feComposite
in2="result8"
operator="arithmetic"
k1="0.5"
k2="0"
k3="0.5"
k4="0"
in="fbSourceGraphic"
result="result10"
id="feComposite3893-8" />
<feTurbulence
baseFrequency="0.07"
numOctaves="3"
type="fractalNoise"
result="result11"
id="feTurbulence3895-9" />
<feDisplacementMap
in2="result11"
scale="10"
xChannelSelector="R"
yChannelSelector="A"
in="result10"
result="result12"
id="feDisplacementMap3897-4" />
<feComposite
in2="result12"
operator="arithmetic"
k1="0.25"
k2="0.25"
k3="0.75"
k4="0"
in="fbSourceGraphic"
result="fbSourceGraphic"
id="feComposite3899-1" />
<feColorMatrix
id="feColorMatrix3901-3"
values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
in="fbSourceGraphic"
result="fbSourceGraphicAlpha" />
<feGaussianBlur
stdDeviation="1"
in="fbSourceGraphic"
result="result0"
id="feGaussianBlur3903-0" />
<feTurbulence
result="result1"
numOctaves="4"
seed="4"
baseFrequency="0.057"
type="turbulence"
id="feTurbulence3905-4" />
<feDisplacementMap
in2="result1"
scale="0"
xChannelSelector="R"
yChannelSelector="A"
result="result91"
id="feDisplacementMap3907-5" />
<feComposite
in2="result91"
operator="out"
in="result0"
result="result2"
id="feComposite3909-9" />
<feComposite
in2="result2"
operator="arithmetic"
k1="0.1"
k2="0"
k3="1.2"
k4="0"
in="fbSourceGraphicAlpha"
result="result5"
id="feComposite3911-3" />
<feBlend
in2="result5"
mode="multiply"
result="fbSourceGraphic"
id="feBlend3913-4" />
<feGaussianBlur
result="result0"
in="fbSourceGraphic"
stdDeviation="3"
id="feGaussianBlur3915-9" />
<feSpecularLighting
specularExponent="15"
specularConstant="0.40000001"
surfaceScale="3"
lighting-color="#fee65d"
result="result1"
in="result0"
id="feSpecularLighting3917-8">
<fePointLight
z="20000"
y="-10000"
x="-5000"
id="fePointLight3919-4" />
</feSpecularLighting>
<feComposite
in2="fbSourceGraphic"
operator="in"
in="result1"
result="result2"
id="feComposite3921-2" />
<feComposite
in2="result2"
operator="arithmetic"
k1="-1"
k2="2.5"
k3="3.5"
k4="0"
in="fbSourceGraphic"
result="result4"
id="feComposite3923-2" />
<feBlend
in2="result4"
mode="multiply"
id="feBlend3925-0" />
</filter>
</defs>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Gear</dc:title>
<dc:date>July 9, 2013</dc:date>
<dc:language>English</dc:language>
<dc:creator>
<cc:Agent>
<dc:title>Devyn Collier Johnson</dc:title>
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title>Creative Commons Share-alike</dc:title>
</cc:Agent>
</dc:rights>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/3.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
id="layer1">
<path
d="m 570.9687,64.734359 c -36.61252,1.90463 -72.25464,7.48805 -106.5625,16.375 l -13.625,104.750001 c -31.37833,12.11451 -60.91033,27.94305 -88.0625,46.9375 l -96.6875,-52.6875 c -27.71546,22.00768 -53.1943,46.70506 -76.0625,73.6875 l 56.125,103.03125 c -15.62666,25.57539 -28.53197,52.9802 -38.375,81.8125 L 82.937455,454.85936 c -9.08954,32.32662 -15.22193,65.88468 -18.09375,100.375 l 122.749995,58.3125 c 2.57204,26.22735 7.58163,51.7195 14.8125,76.28125 l -105.187505,99.5 c 11.560445,30.69658 25.861415,60.06147 42.593755,87.78122 l 151.25,-28.24997 c 14.83722,16.58057 31.00892,31.95537 48.3125,45.96877 l -29.375,157.21867 c 26.38869,16.9357 54.37563,31.5838 83.65625,43.75 L 506.56245,976.45323 c 19.78378,4.5587 40.12085,7.6986 60.875,9.3124 l 71.03125,149.49997 c 31.6796,-2.2872 62.5832,-7.3537 92.5001,-14.9062 l 21.0938,-162.09367 c 20.0354,-7.906 39.2901,-17.328 57.6562,-28.125 l 139.9688,76.24987 c 24.2057,-20.90717 46.5194,-43.93997 66.6562,-68.81237 L 943.6876,804.26561 c 13.6428,-20.20157 25.5389,-41.69571 35.5,-64.21875 l 142.6874,-18.5625 c 7.3808,-31.964 11.8985,-65.00807 13.2813,-98.875 L 1014.3438,565.20311 C 1013.832,535.92741 1010.2819,507.4158 1004,479.92186 l 90.5626,-85.6875 c -13.4536,-32.29171 -29.9658,-62.98527 -49.1876,-91.71875 l -113.9062,21.28125 c -19.4899,-25.92424 -41.9496,-49.48954 -66.875,-70.1875 l 20.0625,-107.4375 C 854.5674,127.22609 822.4745,111.19005 788.75,98.453109 L 716.5313,174.79686 C 684.3067,165.37395 650.456,159.73765 615.49994,158.45311 L 570.96869,64.734359 z m 29.03125,281.687501 c 127.55215,0 230.96885,103.41669 230.96885,230.96875 0,127.55206 -103.4167,230.9375 -230.96885,230.9375 -127.55206,0 -230.96875,-103.38544 -230.96875,-230.9375 0,-127.55206 103.41669,-230.96875 230.96875,-230.96875 z"
id="path2997"
style="fill:#803300;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;filter:url(#filter3845-3)" />
<animateTransform attributeName="transform" attributeType="XML" type="rotate" values="0 0 0; 45 0 0; 90 0 0; 135 0 0; 180 0 0; 225 0 0; 270 0 0; 315 0 0" begin="0s" dur="5s" additive="sum" repeatCount="indefinite"/>
</g>
</svg>

I figured out my issue. The cog is in the center of a 1200x1200 image. My center point is 600x600. In the animate tag, I was using 0x0 as the center.

Related

How to use a matrix with a circle as a mask?

I'm new in MATLAB and using it for some medical analysis. I have a matrix which contains a circular shape in it. Here is a sample:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 1 0 1 1 0 0 0
0 0 1 0 0 0 0 1 0 0
0 1 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 1 1 0 0 0
0 0 0 0 1 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
This matrix has been computed by this line:
egslbr= edge(slbr,'log');
Where slbr is my image. By merging the egslbr with my slbr I get the image bellow.
I want to cancel all the color pixel outside the greenish circle. Is there any way to do this?
You should be able to create a mask from your circle (assuming it's a complete circle -- the sample matrix you gave has a gap in it which makes this much more difficult, but I'm going to assume that was a mistake). Here's a simple way of doing it:
mask = ~cumsum(egslbr) | ~cumsum(egslbr,'reverse');
slbr(mask) = 0;
This should set every pixel outside the circle (not including the edge of the circle though) to zero.

How to debug URL_REQUEST that timed out while uploading large file on MacOS Chrome Browser?

I am trying to upload a 57.86GB file to an azure storage blob container and noticing that it fails regularly only on Chrome 75.0.3770.100 (Official Build) (64-bit) on MacOS Mojave 10.14.3
We are splitting the file into 4MB blocks and have 6 connections open.
When it fails, the PUT request stalls/timesout and the upload halts.
Has anyone run across similar issues? Does anyone have an idea as to where to look next to debug this issue?
Here are the logs that we got from chrome://net-export
285748: URL_REQUEST
https://i_removed_this.blob.core.windows.net/i_removed_this
Start Time: 2019-06-21 14:34:34.320
t=178854 [st= 0] +REQUEST_ALIVE [dt=30624]
--> priority = "MEDIUM"
--> url = "https://i_removed_this.blob.core.windows.net/i_removed_this"
t=178855 [st= 1] NETWORK_DELEGATE_BEFORE_URL_REQUEST [dt=0]
t=178855 [st= 1] +URL_REQUEST_START_JOB [dt=30623]
--> load_flags = 832 (DO_NOT_SAVE_COOKIES | DO_NOT_SEND_AUTH_DATA | DO_NOT_SEND_COOKIES)
--> method = "PUT"
--> privacy_mode = 1
--> upload_id = "0"
--> url = "https://i_removed_this.blob.core.windows.net/i_removed_this"
t=178855 [st= 1] NETWORK_DELEGATE_BEFORE_START_TRANSACTION [dt=0]
t=178855 [st= 1] HTTP_CACHE_GET_BACKEND [dt=0]
t=178855 [st= 1] HTTP_CACHE_OPEN_OR_CREATE_ENTRY [dt=0]
--> net_error = -2 (ERR_FAILED)
t=178855 [st= 1] +HTTP_STREAM_REQUEST [dt=0]
t=178855 [st= 1] HTTP_STREAM_JOB_CONTROLLER_BOUND
--> source_dependency = 285750 (HTTP_STREAM_JOB_CONTROLLER)
t=178855 [st= 1] HTTP_STREAM_REQUEST_BOUND_TO_JOB
--> source_dependency = 285751 (HTTP_STREAM_JOB)
t=178855 [st= 1] -HTTP_STREAM_REQUEST
t=178855 [st= 1] UPLOAD_DATA_STREAM_INIT [dt=1]
--> is_chunked = false
--> net_error = 0 (?)
--> total_size = 4000000
t=178856 [st= 2] +HTTP_TRANSACTION_SEND_REQUEST [dt=185]
t=178856 [st= 2] HTTP_TRANSACTION_SEND_REQUEST_HEADERS
--> PUT /i_removed_this HTTP/1.1
Host: i_removed_this.blob.core.windows.net
Connection: keep-alive
Content-Length: 4000000
Accept: application/json, text/plain, */*
Origin: https://i_removed_this.com/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Content-Type: application/json;charset=utf-8
Referer: https://i_removed_this.com/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
t=178856 [st= 2] HTTP_TRANSACTION_SEND_REQUEST_BODY
--> did_merge = false
--> is_chunked = false
--> length = 4000000
t=178856 [st= 2] UPLOAD_DATA_STREAM_READ [dt=1]
--> current_position = 0
t=178857 [st= 3] UPLOAD_DATA_STREAM_READ [dt=0]
--> current_position = 16384
t=178857 [st= 3] UPLOAD_DATA_STREAM_READ [dt=0]
--> current_position = 32768
... removed most of the UPLOAD_DATE_STREAM_READ events for conciceness
t=179040 [st= 186] UPLOAD_DATA_STREAM_READ [dt=0]
--> current_position = 3981312
t=179041 [st= 187] UPLOAD_DATA_STREAM_READ [dt=0]
--> current_position = 3997696
t=179041 [st= 187] UPLOAD_DATA_STREAM_READ [dt=0]
--> current_position = 4000000
t=179041 [st= 187] -HTTP_TRANSACTION_SEND_REQUEST
t=179041 [st= 187] +HTTP_TRANSACTION_READ_HEADERS [dt=30437]
t=179041 [st= 187] HTTP_STREAM_PARSER_READ_HEADERS [dt=30437]
--> net_error = -7 (ERR_TIMED_OUT)
t=209478 [st=30624] -HTTP_TRANSACTION_READ_HEADERS
--> net_error = -7 (ERR_TIMED_OUT)
t=209478 [st=30624] -URL_REQUEST_START_JOB
--> net_error = -7 (ERR_TIMED_OUT)
t=209478 [st=30624] URL_REQUEST_DELEGATE_RESPONSE_STARTED [dt=0]
t=209478 [st=30624] -REQUEST_ALIVE
--> net_error = -7 (ERR_TIMED_OUT)
285750: HTTP_STREAM_JOB_CONTROLLER
https://i_removed_this.blob.core.windows.net/i_removed_this
Start Time: 2019-06-21 14:34:34.321
t=178855 [st=0] +HTTP_STREAM_JOB_CONTROLLER [dt=0]
--> is_preconnect = false
--> url = "https://i_removed_this.blob.core.windows.net/i_removed_this"
t=178855 [st=0] HTTP_STREAM_JOB_CONTROLLER_BOUND
--> source_dependency = 285748 (URL_REQUEST)
t=178855 [st=0] +PROXY_RESOLUTION_SERVICE [dt=0]
t=178855 [st=0] PROXY_RESOLUTION_SERVICE_RESOLVED_PROXY_LIST
--> pac_string = "DIRECT"
t=178855 [st=0] -PROXY_RESOLUTION_SERVICE
t=178855 [st=0] HTTP_STREAM_JOB_CONTROLLER_PROXY_SERVER_RESOLVED
--> proxy_server = "DIRECT"
t=178855 [st=0] HTTP_STREAM_REQUEST_STARTED_JOB
--> source_dependency = 285751 (HTTP_STREAM_JOB)
t=178855 [st=0] -HTTP_STREAM_JOB_CONTROLLER
285751: HTTP_STREAM_JOB
https://i_removed_this.blob.core.windows.net/
Start Time: 2019-06-21 14:34:34.321
t=178855 [st=0] +HTTP_STREAM_JOB [dt=0]
--> expect_spdy = false
--> original_url = "https://i_removed_this.blob.core.windows.net/"
--> priority = "MEDIUM"
--> source_dependency = 285750 (HTTP_STREAM_JOB_CONTROLLER)
--> url = "https://i_removed_thisblob.core.windows.net/"
--> using_quic = false
t=178855 [st=0] HTTP_STREAM_JOB_WAITING [dt=0]
--> should_wait = false
t=178855 [st=0] +HTTP_STREAM_JOB_INIT_CONNECTION [dt=0]
t=178855 [st=0] +HOST_RESOLVER_IMPL_REQUEST [dt=0]
--> address_family = 0
--> allow_cached_response = true
--> host = "i_removed_this.windows.net:443"
--> is_speculative = false
t=178855 [st=0] HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK
--> cached = true
--> ipv6_available = false
t=178855 [st=0] -HOST_RESOLVER_IMPL_REQUEST
--> net_error = -804 (ERR_DNS_CACHE_MISS)
t=178855 [st=0] TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKET
--> group_id = "i_removed_this.blob.core.windows.net:443"
t=178855 [st=0] +SOCKET_POOL [dt=0]
t=178855 [st=0] SOCKET_POOL_REUSED_AN_EXISTING_SOCKET
--> idle_ms = 3
t=178855 [st=0] SOCKET_POOL_BOUND_TO_SOCKET
--> source_dependency = 253875 (SOCKET)
t=178855 [st=0] -SOCKET_POOL
t=178855 [st=0] -HTTP_STREAM_JOB_INIT_CONNECTION
t=178855 [st=0] HTTP_STREAM_JOB_BOUND_TO_REQUEST
--> source_dependency = 285748 (URL_REQUEST)
t=178855 [st=0] -HTTP_STREAM_JOB
The difference between this and a successfull URL_request is that the URL_REQUEST doesn't time out and we are properly able to read the response headers as seen below:
t=179171 [st=321] +HTTP_TRANSACTION_READ_HEADERS [dt=225]
t=179171 [st=321] HTTP_STREAM_PARSER_READ_HEADERS [dt=225]
t=179396 [st=546] HTTP_TRANSACTION_READ_RESPONSE_HEADERS
--> HTTP/1.1 201 Created
Content-Length: 0
Content-MD5: i_removed_this
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: i_removed_this
x-ms-version: 2017-04-17
x-ms-request-server-encrypted: true
Access-Control-Expose-Headers: x-ms-request-id,Server,x-ms-version,Content-MD5,x-ms-request-server-encrypted,Content-Length,Date,Transfer-Encoding
Access-Control-Allow-Origin: *
Date: Fri, 21 Jun 2019 21:34:34 GMT
t=179396 [st=546] -HTTP_TRANSACTION_READ_HEADERS
t=179396 [st=546] NETWORK_DELEGATE_HEADERS_RECEIVED [dt=0]
t=179396 [st=546] -URL_REQUEST_START_JOB
t=179396 [st=546] URL_REQUEST_DELEGATE_RESPONSE_STARTED [dt=0]
t=179396 [st=546] HTTP_TRANSACTION_READ_BODY [dt=0]
t=179396 [st=546] -REQUEST_ALIVE
The socket does timeout after about 30 seconds.
t=179042 [st=179041] SOCKET_BYTES_SENT
--> byte_count = 3128
t=179042 [st=179041] SOCKET_BYTES_SENT
--> byte_count = 2449
t=209478 [st=209477] SOCKET_READ_ERROR
--> net_error = -7 (ERR_TIMED_OUT)
--> os_error = 60
t=209478 [st=209477] SSL_READ_ERROR
--> error_lib = 33
--> error_reason = 7
--> file = "../../net/socket/socket_bio_adapter.cc"
--> line = 154
--> net_error = -7 (ERR_TIMED_OUT)
--> ssl_error = 1
And in our azure storage blob logs, we can see that it returns a 500 SasNetworkError on the PUT block which shows that the client closed the connection before the timeout expiration.
Our web app will normally retry the PUT request on 500 errors. However, on Mac Chrome it seems that we didn't detect it.
Also, not sure if the following information is relevant, but after the timed out URL_REQUEST, we started to make requests to "ws://127.0.0.1:6263/4":
285774: URL_REQUEST
ws://127.0.0.1:6263/4
Start Time: 2019-06-21 14:34:35.929
t=180463 [st=0] +REQUEST_ALIVE [dt=1]
--> priority = "LOWEST"
--> url = "ws://127.0.0.1:6263/4"
t=180463 [st=0] NETWORK_DELEGATE_BEFORE_URL_REQUEST [dt=0]
t=180463 [st=0] +URL_REQUEST_START_JOB [dt=1]
--> load_flags = 18 (BYPASS_CACHE | DISABLE_CACHE)
--> method = "GET"
--> privacy_mode = 0
--> url = "ws://127.0.0.1:6263/4"
t=180463 [st=0] NETWORK_DELEGATE_BEFORE_START_TRANSACTION [dt=0]
t=180463 [st=0] HTTP_CACHE_GET_BACKEND [dt=0]
t=180463 [st=0] +HTTP_STREAM_REQUEST [dt=1]
t=180463 [st=0] HTTP_STREAM_JOB_CONTROLLER_BOUND
--> source_dependency = 285775 (HTTP_STREAM_JOB_CONTROLLER)
t=180464 [st=1] HTTP_STREAM_REQUEST_BOUND_TO_JOB
--> source_dependency = 285776 (HTTP_STREAM_JOB)
t=180464 [st=1] -HTTP_STREAM_REQUEST
t=180464 [st=1] -URL_REQUEST_START_JOB
--> net_error = -102 (ERR_CONNECTION_REFUSED)
t=180464 [st=1] URL_REQUEST_DELEGATE_RESPONSE_STARTED [dt=0]
t=180464 [st=1] -REQUEST_ALIVE
--> net_error = -102 (ERR_CONNECTION_REFUSED)

Fortran- Inverse Matrix result not same if Decimal is longer

My real data is first input but inverse of result is so big. They are same data when you compare with first and second input. There is only difference decimal size. Why is there different result? Because they are same data. How can they have different result? You can see result and input. It is so strange.
program test
Implicit none
double precision,allocatable,dimension(:,:) :: A
double precision,allocatable,dimension(:) :: WORK
integer ,allocatable,dimension(:) :: ipiv
integer :: n,info,M
external DGETRF,DGETRI
M=8
allocate(A(M,M),WORK(M),IPIV(M))
!!! First Input !!!!
A(1,:)=(/3.740486048842566D-4, 0.0D0, 0.0D0, 4.987315029057229D-5, 0.0D0, 0.0D0, 0.0D0, 0.0D0/)
A(2,:)=(/0.0D0 , 3.740486048842566D-4, 0.0D0, 0.0D0, 4.987315029057229D-5 ,0.0D0 ,0.0D0 ,0.0D0 /)
A(3,:)=(/0.0D0 , 0.0D0 ,3.740486048842566D-4, 0.0D0 ,0.0D0, 4.987315029057229D-5, 0.0D0 ,0.0D0/)
A(4,:)=(/4.987315029057229D-5 ,0.0D0 ,0.0D0 ,6.649753768432517D-6, 0.0D0 ,0.0D0, 0.0D0, 0.0D0 /)
A(5,:)=(/0.0D0 , 4.987315029057229D-5, 0.0D0, 0.0D0 ,6.649753768432517D-6 ,0.0D0 ,0.0D0 ,0.0D0 /)
A(6,:)=(/0.0D0, 0.0D0, 4.987315029057229D-5, 0.0D0 ,0.0D0, 6.649753768432517D-6, 0.0D0 ,0.0D0 /)
A(7,:)=(/0.0D0, 0.0D0 ,0.0D0, 0.0D0 ,0.0D0 ,0.0D0 ,1.499999910593033D-11, 0.0D0 /)
A(8,:)=(/0.0D0 ,0.0D0 ,0.0D0 ,0.0D0 ,0.0D0 ,0.0D0, 0.0D0 ,1.499999910593033D-11 /)
!!!! Second Input !!!!
!A(1,:)=(/3.74D-4, 0.0D0, 0.0D0, 4.98D-5, 0.0D0, 0.0D0, 0.0D0, 0.0D0/)
!A(2,:)=(/0.0D0 , 3.74D-4, 0.0D0, 0.0D0, 4.98D-5 ,0.0D0 ,0.0D0 ,0.0D0 /)
!A(3,:)=(/0.0D0 , 0.0D0 ,3.74D-4, 0.0D0 ,0.0D0, 4.98D-5, 0.0D0 ,0.0D0/)
!A(4,:)=(/4.98D-5 ,0.0D0 ,0.0D0 ,6.64D-6, 0.0D0 ,0.0D0, 0.0D0, 0.0D0 /)
!A(5,:)=(/0.0D0 , 4.98D-5, 0.0D0, 0.0D0 ,6.64D-6 ,0.0D0 ,0.0D0 ,0.0D0 /)
!A(6,:)=(/0.0D0, 0.0D0, 4.98D-5, 0.0D0 ,0.0D0, 6.64D-6, 0.0D0 ,0.0D0 /)
!A(7,:)=(/0.0D0, 0.0D0 ,0.0D0, 0.0D0 ,0.0D0 ,0.0D0 ,1.49D-11, 0.0D0 /)
!A(8,:)=(/0.0D0 ,0.0D0 ,0.0D0 ,0.0D0 ,0.0D0 ,0.0D0, 0.0D0 ,1.49D-11 /)
call DGETRF(M,M,A,M,IPIV,info)
if(info .eq. 0) then
Print *,'succeded'
else
Print *,'failed'
end if
call DGETRI(M,A,M,IPIV,WORK,M,info)
if(info .eq. 0) then
Print *,'succeded'
else
Print *,'failed'
end if
Print *,A
deallocate(A,IPIV,WORK)
end
!!!!! Second Input Result
!1.0e+10 *
! 0.0002 0 0 -0.0015 0 0 0 0
! 0 0.0002 0 0 -0.0015 0 0 0
! 0 0 0.0002 0 0 -0.0015 0 0
! -0.0015 0 0 0.0113 0 0 0 0
! 0 -0.0015 0 0 0.0113 0 0 0
! 0 0 -0.0015 0 0 0.0113 0 0
! 0 0 0 0 0 0 6.7114 0
! 0 0 0 0 0 0 0 6.7114
!!! First Input Result
! 1.0e+21 *
!-0.0238 0 0 0.1783 0 0 0 0
! 0 -0.0238 0 0 0.1783 0 0 0
! 0 0 0.0000 0 0 -0.0000 0 0
! 0.1783 0 0 -1.3375 0 0 0 0
! 0 0.1783 0 0 -1.3375 0 0 0
! 0 0 -0.0000 0 0 0.0000 0 0
! 0 0 0 0 0 0 0.0000 0
! 0 0 0 0 0 0 0 0.0000
Creating a matrix inverse is not a difficult problem.
I converted your earlier example to using a simple approach, based on Gaussian elimination with a shadowed identity matrix, which works well for most cases. The attached program inverts your earlier symmetric matrix, without resorting to pivoting of the rows. It does not need a "black-box".
That you get different results with different coefficients is hardly surprising. With the significant change in results for apparently small changes of input values, shows the sensitivity and possibly poor conditioning of the equation relationship you are using.
https://www.dropbox.com/s/ssotjx45yrz5sf9/dgetri.f90?dl=0
Additional response re "First Input"
https://www.dropbox.com/s/hximfoin977rmov/dgetri_piv4.f90?dl=0
This latest link (16-6) has both data sets included. In "First Input", your equations basically are rows 4:6 are rows 1:3 / 7.5 + small_noise.
This latest code example has accuracy checks both during the matrix inversion and also after. The during test checks the row changes are correct, while the after checks are "A.A^-1 - I" and "A - (A^-1)^-1", which better indicate poor accuracy.
It is interesting that "Second Input" (with more noise) reports a reasonably accurate outcome. Failing to get an inverse with 8-byte reals needs a fairly contrived matrix ! Similarly, the random number derived coefficients examples shows good accuracy.
These examples show that the accuracy tests I have presented don't always identify poorly defined equation relationships. Your inspection of the inverse to identify large variation in values is also useful.
Given the way the equations appear to have been defined, I am not sure what is the outcome you are wanting.

How to sort pandas dataframe non-lexical?

What I do to sort credit in the following dataframe is to use sort_values() function (I've also tried sort()):
df.sort_values('credit', ascending=False, inplace=True)
The problem is that credits are sorted like below:
i credit m reg_date b id
----------------------------------------------------------------------
238 0 4600000.00 0 2014-04-14 False 102214
127 0 4600000.00 0 2014-12-30 False 159479
13 0 16800000.00 0 2015-01-12 False 163503
248 0 16720000.00 0 2012-11-11 False 5116
Ascending is False that's why 4600000.00 is before other credits. But this is not what I wanted. I wanted to sort based on the values. So in the sample above 16800000.00 and 16720000.00 should be before 4600000.00. How to sort this Dataframe non-lexical?
EDIT-1:
Data is more than that and can contain:
120 0 16708000.00 0 2013-12-17 False 51433
248 0 16720000.00 0 2012-11-11 False 5116
13 0 16800000.00 0 2015-01-12 False 163503
21 0 4634000.00 0 2014-12-29 False 159239
136 0 4650000.00 0 2012-11-07 False 4701
.. ... ... ... ... ... ...
231 0 7715000.00 0 2014-02-15 False 83936
182 0 7750000.00 0 2015-07-13 False 201584
You could sort the column separately as type float and use the index to slice the original index
In your case:
import pandas as pd
from StringIO import StringIO
text = """136 0 4650000.00 0 2012-11-07 False 4701
231 0 7715000.00 0 2014-02-15 False 83936
13 0 16800000.00 0 2015-01-12 False 163503
120 0 16708000.00 0 2013-12-17 False 51433
248 0 16720000.00 0 2012-11-11 False 5116
21 0 4634000.00 0 2014-12-29 False 159239
182 0 7750000.00 0 2015-07-13 False 201584
"""
df = pd.read_csv(StringIO(text), delim_whitespace=True,
header=None, index_col=0,
names=['i', 'credit', 'm', 'reg_date', 'b', 'id'])
print df.loc[df.credit.astype(float).sort_values(ascending=False).index]
i credit m reg_date b id
13 0 16800000.0 0 2015-01-12 False 163503
248 0 16720000.0 0 2012-11-11 False 5116
120 0 16708000.0 0 2013-12-17 False 51433
182 0 7750000.0 0 2015-07-13 False 201584
231 0 7715000.0 0 2014-02-15 False 83936
136 0 4650000.0 0 2012-11-07 False 4701
21 0 4634000.0 0 2014-12-29 False 159239

Swift - Reading .jpg image for pixel color returning incorrect values

I'm trying to get the UIColor of each pixel from a jpg image in swift, the following code successfully gets each pixel color however the results are confusing me:
func renderLandscape() {
var landscapeImage = UIImage(named: "test")
for var xPos = 0 as CGFloat; xPos < landscapeImage?.size.width; xPos++ {
for var yPos = 0 as CGFloat; yPos < landscapeImage?.size.height; yPos++ {
var currentColor = landscapeImage?.getPixelColor(CGPointMake(xPos, yPos))
NSLog("Color: %#", currentColor!)
}
}
}
I've created an extension of UIImage here:
extension UIImage {
func getPixelColor(pos: CGPoint) -> UIColor {
var pixelData = CGDataProviderCopyData(CGImageGetDataProvider(self.CGImage))
var data: UnsafePointer<UInt8> = CFDataGetBytePtr(pixelData)
var pixelInfo: Int = ((Int(self.size.width) * Int(pos.y)) + Int(pos.x)) * 4
//NSLog("Data: %#", data.encode())
var r = CGFloat(data[pixelInfo]) / CGFloat(255.0)
var g = CGFloat(data[pixelInfo+1]) / CGFloat(255.0)
var b = CGFloat(data[pixelInfo+2]) / CGFloat(255.0)
var a = CGFloat(data[pixelInfo+3]) / CGFloat(255.0)
return UIColor(red: r, green: g, blue: b, alpha: a)
}
}
Obviously the output is extremely long however here is the first 41 lines (the first column of the image):
2015-05-12 22:21:58.793 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.793 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.794 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.795 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.795 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.795 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.797 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.798 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.798 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.798 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.798 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.798 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.799 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.799 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.799 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.799 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.799 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.814 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.814 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.814 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.814 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.814 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.814 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.815 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.815 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.815 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0 0 1
2015-05-12 22:21:58.815 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0.00392157 0 1
2015-05-12 22:21:58.815 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0.00392157 0 1
2015-05-12 22:21:58.830 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0.0470588 0 1
2015-05-12 22:21:58.831 Game[6542:220967] Color: UIDeviceRGBColorSpace 0 0.141176 0 1
2015-05-12 22:21:58.831 Game[6542:220967] Color: UIDeviceRGBColorSpace 0.627451 0.694118 0.317647 1
2015-05-12 22:21:58.832 Game[6542:220967] Color: UIDeviceRGBColorSpace 0.756863 0.121569 0 1
2015-05-12 22:21:58.832 Game[6542:220967] Color: UIDeviceRGBColorSpace 0.996078 0 0 1
2015-05-12 22:21:58.832 Game[6542:220967] Color: UIDeviceRGBColorSpace 0.996078 0.00392157 0 1
The fist 32 lines are UIDeviceRGBColorSpace 0 0 0 1, which is correct (Black) however after that there should be four more black pixels a green (#2aff00) and three red (#ff0000) except there are 8 non black pixels, each with a different color value.
Here is the image which was created in Photoshop:
Why aren't any of the red colors the same in RGB and why are there 8 non black pixels?
Thanks in advance, Johann
Okay so after a fair bit of struggling I tried saving my image as a PNG file. Fixed everything.
According to a friend JPG images kind of blur between the pixel colours where as PNG will keep each pixel a solid colour. Using PNG for this type of work is much more reliable. - Excuse me for my non-technical talk.
Thank you.

Resources