How can I do FOCAL MECHANISMS on Generic Mapping Tools (GMT)? - gis

I've made some FOCAL MECHANISMS (FM) for the north part of Southamerica on GMT, and I need to put them on a map.
For the FM I have a document with 85 earthquakes and this is the code:
psmeca eventos2.dat -R-80/-66/-5/14 -JM6i -Sm0.4/0/0.05u -P -V > coltopomap.ps
GMT psconvert coltopomap.ps -Tf
And this is the map
GMT grdcut topo15.grd -R-80/-66/-5/14 -Gtopo15_cut_col.grd
GMT grdgradient topo15_cut_col.grd -Gtopo15_cut_shaded.grd -A310 -Ne0.6
GMT grdimage topo15_cut_col.grd -JM6i -R-80/-66/-5/14 -Cglobe -P -Ba --MAP_FRAME_TYPE=plain --MAP_GRID_CROSS_SIZE_PRIMARY=0p -Itopo15_cut_shaded.grd -K > coltopomap.ps
GMT pscoast -R-80/-66/-5/14 -J -Df -N1/1,black -W1/0.5,black -Lf-68/-4/-68/-4/200k+l -Tdg-78/12+w0.3i+f3+lW,E,S,N --FONT_ANNOT=10p --FONT_LABEL=10p --FONT_TITLE=10p -O >> coltopomap.ps
To join them I've tried with
GMT grdcut topo15.grd -R-80/-66/-5/14 -Gtopo15_cut_col.grd
GMT grdgradient topo15_cut_col.grd -Gtopo15_cut_shaded.grd -A310 -Ne0.6
GMT grdimage topo15_cut_col.grd -JM6i -R-80/-66/-5/14 -Cglobe -P -Ba --MAP_FRAME_TYPE=plain --MAP_GRID_CROSS_SIZE_PRIMARY=0p -Itopo15_cut_shaded.grd -K > coltopomap.ps
GMT pscoast -R-80/-66/-5/14 -J -Df -N1/1,black -W1/0.5,black -Lf-68/-4/-68/-4/200k+l -Tdg-78/12+w0.3i+f3+lW,E,S,N --FONT_ANNOT=10p --FONT_LABEL=10p --FONT_TITLE=10p -O >> coltopomap.ps
GMT psmeca eventos2.dat -R-80/-66/-5/14 -JM6i -Sm0.4/0/0.05u -P -V >> coltopomap.ps
GMT psconvert coltopomap.ps -Tf
But the only thing I get is the map in one page and the FM in another as you can see in the next image:
https://i.stack.imgur.com/bAvx7.png

It seems you are missing the -K flag from your GMT pscoast ... command.
From GMT documentation:
Required for all but the last plot command when building multi-layer
plots

Related

401 Unauthorized with JSON

I got an error when i run the bash script below.
pi#raspberrypi:~/dev-domoticz/scripts $ ./dht_22.sh
21.2
48.2
HTTP/1.1 401 Unauthorized
Content-Length: 91
Content-Type: text/html
Set-Cookie: SID=none; HttpOnly; Expires=Thu, 01 Jan 1970 00:00:00 GMT
<html><head><title>Unauthorized</title></head><body><h1>
This script reads the DHT22 chip for temp and humidity dht_22.sh and communicate with the Domoticz server with json. So i can see the current temp/humi on my Domoticz server:
#!/bin/sh
# Domoticz server
SERVER="10.0.0.110:8080"
# DHT IDX
DHTIDX="4"
# DHTPIN
DHTPIN="4"
# TEMP FILE
TMPFILE="/var/tmp/temp.txt"
cpt=0
while [ $cpt -lt 6 ]
do
TEMP=""
sleep 5
sudo nice -20 /home/pi/dev-domoticz/scripts/Adafruit_Python_DHT/examples/AdafruitDHT.py 22 $DHTPIN > /var/tmp/temp.t$
#TEMP=$(cat /var/tmp/temp.txt | grep "Temp" | awk '{ print $3 }')
#TEMP=$(cat /var/tmp/temp.txt | grep "Temp")
TEMP=$(awk ' /Temp/ {print substr ($0,6,4)}' /var/tmp/temp.txt)
HUM=$(awk ' /Humidity/ {print substr ($0,22,4)}' /var/tmp/temp.txt)
echo $TEMP
echo $HUM
# Send data
curl -s -i -H "Accept: application/json" "http://10.0.0.110:8080/json.htm?type=command&param=udevice&idx=$DHTIDX&nv$
TEMP=""
HUM=""
exit 0
cpt=$(($cpt+1))
done
exit 1
When i just run the json line in a browser, i also receive a 401 Unauthorized error.
I gues i have to enter some login information, so i also tryed something like this:
http://10.0.0.110:8080/json.htm?username=test=&password=test=&type=command&param=udevice&idx=4&nvalue=0&svalue=21;40;2
But still the 401 error.
Can some one help me out?
Well, cost me some time but it work now.
Your solution was correct Viktor Khilin but my Domoticz software gave me some problems.
The solution was this:
curl -s -i -H "Accept: application/json" "http://10.0.0.110:8080/json.htm?&username=test=&password=test=&type=command&param=udevice&idx=$DHTIDX&nvalue=0&svalue=$TEMP;$HUM;2"
Thanks for helping me out.

ESP8266 client connection to MongoDB

I'm trying to post a new record to my MongoDB (actual CouchDB), but it seems that I'm having problems with the format of my request.
I'm using the following code:
(not showing debug and validations)
WiFiClient client;
client.connect("172.16.1.4", 5984)
String connStr = "POST /iot/ HTTP/1.1\r\n"
"Host: user:password#172.16.1.4:5984/ \r\n"
"Content-Type: application/json\r\n"
"\r\n"
"'{\"a\":1}'\r\n\r\n";
client.print(connStr);
I get this response back:
HTTP/1.1 400 Bad Request
Server: CouchDB/1.6.1 (Erlang OTP/18)
Date: Sat, 07 Oct 2017 11:57:50 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 48 Cache-Control: must-revalidate
{"error":"bad_request","reason":"invalid_json"}
HTTP/1.1 400 Bad
Request Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Sat, 07 Oct 2017 11:57:50 GMT
Content-Length: 0
I have tried with differet json/data...
Using Linux - I have no problems:
curl -X POST user:password#172.16.1.4:5984/iot/ -H "Content-Type: application/json" -d '{"a":3}'
The issue might be with the single quotes(') before { and at the end of }
instead of
"'{\"a\":1}'\r\n\r\n"
it should be
"{\"a\":1}\r\n\r\n"
I was missing the line:
"Content-Length: " + String(json.length()) + "\r\n"
in the header.

Error Accessing Data Volumes for MobileFirst Platform Analytics Container on Bluemix

I am creating MobileFirst container groups on Bluemix. My issue is with creating the Analytics container group. I have edited the appropriate .properties files, and in args/startanalyticsgroup.properties, I have set ENABLE_ANALYTICS_DATA_VOLUME=Y and ANALYTICS_DATA_VOLUME_NAME=mfp_analytics_$ANALYTICS_CONTAINER_GROUP_NAME.
When I execute the ./startanalyticsgroup.sh args/startanalyticsgroup.properties the volume gets created successfully. However, as the script continues to process it throws an error saying the data volume cannot be retrieved. The error message is below. Thank you in advance for any assistance you can provide.
./startanalyticsgroup.sh args/startanalyticsgroup.properties
Arguments :
-----------
ANALYTICS_IMAGE_NAME : registry.ng.bluemix.net/dockercontainerrepo/mfpanalytics71
ANALYTICS_CONTAINER_GROUP_NAME : mfpAnalytics
ANALYTICS_CONTAINER_GROUP_MIN : 1
ANALYTICS_CONTAINER_GROUP_MAX : 2
ANALYTICS_CONTAINER_GROUP_DESIRED : 1
ENABLE_AUTORECOVERY : Y
ANALYTICS_CONTAINER_GROUP_HOST : mfpanalytics
ANALYTICS_CONTAINER_GROUP_DOMAIN : mybluemix.net
SERVER_MEM : 2048
TRACE_SPEC :
MAX_LOG_FILES :
MAX_LOG_FILE_SIZE :
MFPF_PROPERTIES :
ENABLE_VOLUME : N
ENABLE_ANALYTICS_DATA_VOLUME : Y
ANALYTICS_DATA_VOLUME_NAME : mfp_analytics_mfpAnalytics
ANALYTICS_DATA_DIRECTORY : /analyticsData
The volume mfp_analytics_mfpAnalytics will be created to store analytics data.
OK
Volume 'mfp_analytics_mfpAnalytics' was created.
Starting the analytics container group : mfpAnalytics
Executing command : cf ic group create --name mfpAnalytics -n mfpanalytics -d mybluemix.net -m 2048 --min 1 --max 2 --desired 1 -p 9080 --auto -v mfp_analytics_mfpAnalytics:/analyticsData -e ANALYTICS_DATA_DIRECTORY=/analyticsData -e ANALYTICS_TRACE_LEVEL=*~info -e ANALYTICS_MAX_LOG_FILES=5 -e ANALYTICS_MAX_LOG_FILE_SIZE=20 registry.ng.bluemix.net/dockercontainerrepo/mfpanalytics71
REQUEST: [2016-05-19T13:43:03-04:00]
POST /UAALoginServerWAR/oauth/token HTTP/1.1
Host: login.ng.bluemix.net
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/x-www-form-urlencoded
User-Agent: go-cli 6.17.0+5d0be0a / darwin
grant_type=refresh_token&refresh_token=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5ZTgzZmQyZS00Y2MxLTQ4OWUtODA1Yi1lYWNjMzcyOWYzNDEtciIsInN1YiI6ImZlMzU4Y2IwLWNmYjYtNDI3MC05NmMyLTYyNzVmNTA5NjI1OCIsInNjb3BlIjpbIm9wZW5pZCIsImNsb3VkX2NvbnRyb2xsZXIucmVhZCIsInBhc3N3b3JkLndyaXRlIiwiY2xvdWRfY29udHJvbGxlci53cml0ZSJdLCJpYXQiOjE0NjM2NzkxNjYsImV4cCI6MTQ2NjI3MTE2NiwiY2lkIjoiY2YiLCJjbGllbnRfaWQiOiJjZiIsImlzcyI6Imh0dHBzOi8vdWFhLm5nLmJsdWVtaXgubmV0L29hdXRoL3Rva2VuIiwiemlkIjoidWFhIiwiZ3JhbnRfdHlwZSI6InBhc3N3b3JkIiwidXNlcl9uYW1lIjoibG9uZ3RAdXMuaWJtLmNvbSIsIm9yaWdpbiI6InVhYSIsInVzZXJfaWQiOiJmZTM1OGNiMC1jZmI2LTQyNzAtOTZjMi02Mjc1ZjUwOTYyNTgiLCJyZXZfc2lnIjoiZmI2ZjZkZmEiLCJhdWQiOlsiY2YiLCJvcGVuaWQiLCJjbG91ZF9jb250cm9sbGVyIiwicGFzc3dvcmQiXX0.QXXRHERyg5JbAg2l8Jx7O7e-JRC4vgwmrgDMWPjm2LQ&scope=
RESPONSE: [2016-05-19T13:43:03-04:00]
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-cache, no-store, max-age=0, must-revalidate,no-store
Connection: Keep-Alive
Content-Type: application/json;charset=UTF-8
Date: Thu, 19 May 2016 17:43:03 GMT
Expires: 0
Pragma: no-cache,no-cache
Server: Apache-Coyote/1.1
X-Backside-Transport: OK OK,OK OK
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Global-Transaction-Id: 1067898045
X-Powered-By: Servlet/3.1
X-Xss-Protection: 1; mode=block
699
{"access_token":"[PRIVATE DATA HIDDEN]","token_type":"bearer","refresh_token":"[PRIVATE DATA HIDDEN]","expires_in":43200,"scope":"cloud_controller.read password.write cloud_controller.write openid","jti":"cd2c3f32-be0e-4b35-acb0-058f0e49fac1"}
0
FAILED
"{\n \"code\": \"IC5051E\", \n \"description\": \"The image registry.ng.bluemix.net/mfp_analytics_mfpAnalytics:/analyticsData could not be retrieved. Verify that the image ID or name is correct.\", \n \"incident_id\": \"740-1463679783.961-19195817\", \n \"name\": \"ImageNotFound\", \n \"rc\": \"404\", \n \"type\": \"Infrastructure\"\n}"
The latest version of 'cf' (6.17+) is now pulling out the -v parameter for its own usage.
Use --volume instead of -v should fix it:
e.g.:
cf ic group create --name mfpAnalytics -n mfpanalytics -d mybluemix.net -m 2048 --min 1 --max 2 --desired 1 -p 9080 --auto --volume mfp_analytics_mfpAnalytics:/analyticsData -e ANALYTICS_DATA_DIRECTORY=/analyticsData -e ANALYTICS_TRACE_LEVEL=*~info -e ANALYTICS_MAX_LOG_FILES=5 -e ANALYTICS_MAX_LOG_FILE_SIZE=20 registry.ng.bluemix.net/dockercontainerrepo/mfpanalytics71
Or, simpler, switch back to cf version 6.16 for now.

JSON Post data empty - Linux curl Command

I am trying to post json data to php file using linux curl command, (Lamp Server)
$ curl -V -H "Content-Type: application/json" -X POST -d '{"id": "123"}'
http://localhost/crm/UpdateUser.php
In UpdateUser.php,
<?php echo var_dump ($_POST);?>
OUTPUT:
[ec2-user#ip-10-35-1-181 ~]$ curl -v -H "Content-Type: application/json" -X POST -d '{"id": "123"}' http://viacrm.odema.net/crm/UpdateUser.php
* Hostname was NOT found in DNS cache
* Trying 54.217.206.217...
> POST /crm/UpdateUser.php HTTP/1.1
> User-Agent: curl/7.36.0
> Host: 192.168.1.16
> Accept: */*
> Content-Type: application/json
> Content-Length: 13
>
* upload completely sent off: 13 out of 13 bytes
< HTTP/1.1 200 OK
< Date: Mon, 16 Jun 2014 12:25:00 GMT
* Server Apache/2.2.27 (Amazon) is not blacklisted
< Server: Apache/2.2.27 (Amazon)
< X-Powered-By: PHP/5.3.28
< Content-Length: 13
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
array(0) {
}
* Closing connection 0
Always the Post data shows empty, I even tried to use "ACCEPT: application/json", still same problem. Please can anyone guide this ?
$_POST only contains the results of decoding an application/x-www-form-urlencoded request. You need to read the raw request body. If you have the always_populate_raw_post_data configuration directive turned on, then the raw body will be in $HTTP_RAW_POST_DATA; otherwise you can obtain it by reading from the php://input stream.
Instead of $_POST try it:
<?php
print($HTTP_RAW_POST_DATA);
?>

Not getting Google-Drive push notifications

I'm following the document https://developers.google.com/drive/push to receive push notifications from Google Drive.
My domain is registered (in the API Access pane in the APIs Console).
I have a custom program in the registered domain listening over htpps (with a Self-signed certificate). https://myveryowndomain.bc.com/drive/notifications
Notification channels are properly created for any change (get response code 200).
I make changes in my Google Drive files but nothing comes to 2, not even the sync message.
Am I missing something?
CONFIG: -------------- REQUEST --------------
POST https://www.googleapis.com/drive/v2/changes/watch
Accept-Encoding: gzip
Authorization: Bearer 1/QRYL1ZHO4KyUmjkbHVWXCWglxJ5e6-xxxxxxxxxxxxx
User-Agent: push-test-project Google-HTTP-Java-Client/1.15.0-rc (gzip)
Content-Type: application/json; charset=UTF-8
Content-Length: 150
Jul 24, 2013 6:02:04 PM com.google.api.client.http.HttpRequest execute
CONFIG: curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: Bearer 1/QRYL1ZHO4KyUmjkbHVWXCWglxJ5e6-xxxxxxxxxxxxx' -H 'User-Agent: push-test-project Google-HTTP-Java-Client/1.15.0-rc (gzip)' -H 'Content-Type: application/json; charset=UTF-8' -d '#-' -- 'https://www.googleapis.com/drive/v2/changes/watch' << $$$
Jul 24, 2013 6:02:04 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 155 bytes
Jul 24, 2013 6:02:04 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {"address":"https://myveryowndomain.bc.com/drive/notifications","id":"f143f7ba-759a-42b8-8748-e39a71ba13cc","type":"web_hook"}
Jul 24, 2013 6:02:08 PM com.google.api.client.http.HttpResponse <init>
CONFIG: -------------- RESPONSE --------------
HTTP/1.1 200 OK
ETag: "RFvxxXV9yoZniidCHgcusodAlXI/AaEAn8d9Ma5bpJZNmM0F72Crxxx"
Content-Length: 247
X-XSS-Protection: 1; mode=block
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Server: GSE
X-Content-Type-Options: nosniff
Pragma: no-cache
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
X-Frame-Options: SAMEORIGIN
Date: Wed, 24 Jul 2013 09:02:08 GMT
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Jul 24, 2013 6:02:08 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: Total: 296 bytes
Jul 24, 2013 6:02:08 PM com.google.api.client.util.LoggingByteArrayOutputStream close
CONFIG: {
"kind": "api#channel",
"id": "f143f7ba-759a-42b8-8748-e39a71ba13cc",
"resourceId": "_X2yFKJJ6yLq3eIrw3OSxxxxxxx",
"resourceUri": "https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true&maxResults=100&alt=json",
"token": "",
"expiration": "1374660126357"
}
Self-signed SSL seems to be the problem here. It's not only about encryption. It's also about trust issue.
You can get free SSL from StartSSL or CACert.
FYI, expires header is not expiration time of the channel. It's information about cache.
Your real expiration time of the channel can be found at "expiration" field of the response body. It is represented in unix time format and your response "1374660126357" is actually "Wed, 01 Apr 45531 03:05:57 GMT". Default expiration time for changes channel is 1 week.