Hi ,
I have a file containing 1 column with absolute times :
> cat test.txt
1980-01-09T09:00:00
1980-01-29T03:00:00
1980-02-14T06:00:00
...
2016-03-13T15:00:00
2016-09-17T15:00:00
2016-10-13T06:00:00
...
I want to plot an histogram with a frequency in y-axis
and months in x-axis
using this command :
gmt begin test01
gmt histogram -JX10c -Ttest.txt -Bxaf+l"Months" -Byaf+l"Frequency"+u"%" -D+r -N0 -Z1 -wa -Glightblue -Wthinnest,black
gmt end show
But it just gets stuck (no error, just infinite loop) :
histogram [DEBUG]: History: Process -JX10c
histogram [INFORMATION]: Processing input table data
histogram [DEBUG]: gmtapi_init_import: Passed family = Data Table and geometry = Volume
histogram [DEBUG]: gmtapi_init_import: Added 0 new sources
histogram [DEBUG]: Object ID 0 : Registered Data Table Stream 7fff88bcfe50 as an Input resource with geometry Volume [n_objects = 1]
histogram [DEBUG]: gmtapi_init_import: Added stdin to registered sources
histogram [DEBUG]: GMT_Init_IO: Returned first Input object ID = 0
histogram [DEBUG]: GMT_Begin_IO: Mode value 1 not considered (ignored)
histogram [DEBUG]: GMT_Begin_IO: Initialize record-by-record access for Input
histogram [DEBUG]: gmtapi_next_io_source: Selected object 0
histogram [INFORMATION]: Reading Data Table from Standard Input stream
histogram [DEBUG]: GMT_Begin_IO: Input resource access is now enabled [record-by-record]
If I add -R0/12/0/100 it doesn’t solve the bug.
Thanks
I think it will work if you just do test.txt
rather than -Ttest.txt
. It is trying to read the data from standard input rather than your text file.
You should be able to instead use -T1
to get annual intervals
Thanks Meghan,
So what’s the -T1 's for ?
-T[min/max]int
is required to set the interval for the bins (leaving off min/max implies they can be read from -R
).
In your example, using -wa
reformats your input data to all be in the range 0 - 12, so -T1
will then bin them every integer which is the same as binning by months thanks to the new -w
option. Similarly -T3
could be used to bin by quarter.
p.s. you can use gmt convert @test.txt -wa > output.txt
to see what -wa
is doing.
1 Like
More practical question … how do I shift the plot to be centered on Winter ?
-wa/[phase] doesn’t work
-E1+o6
doesn’t cycle
You can use -R
to control the center value. For example: -R-5/7/0/8
would set the first bin to August.
Awesome.
I didn’t think about assigning negative values.
Puuurfect
Satisfying result :
- Transform indices from file to absolute time :
# The data of interest are in the first column of event_index.txt
# The time-step in my original file is 3 hours
gmt math -o0 -foT -C0 event_index.txt 3 MUL 3 SUB --TIME_EPOCH=1980-01-01 --TIME_UNIT=h = test.txt
- Plot the annual frequency histogram centered on winter :
# First month is August, the last is July
gmt begin test01 png
gmt histogram -R-5/7/0/20 -JX10c test.txt -T1 -BWSen -Bxa1Of1O+l"Months" -Byaf+l"Frequency"+u"%" -D+r -Z1 -wa -Glightblue -Wthinnest,black --FORMAT_TIME_PRIMARY_MAP=c
gmt end
1 Like
Very nice! It confirms the old Wessel saying “There is nothing GMT cannot do as long as we code up what it is we want it to do”.
Indeed !
However the -N option is weird … (I don’t need it, but you might want to have a look at how it’s plotted)
We have tests that use -N that looks fine, but that predates -w. If you have a strange example, then please share.
Taking the example above,
- I removed
-R
(starts in January)
- I added
-N0
I will reluctantly agree with you that this is not the expected curve. Could you please post test.txt so I can reproduce?
thank you - will try to give it a test this weekend.
Please provide me the idea to plot the below magnitude plot, based on color indication.
I would say simply histogram
module in combination with -C
option right ?