Problems with annotations in script

Post any questions, ideas, or topics related to Jython and Python scripting.
User avatar
Weathernator
Posts: 8
Joined: Mon Dec 09, 2013 4:42 pm

Problems with annotations in script

Post by Weathernator »

My problem is with Annotations in other areas ,close, but not lining up whatsoever.

I'll have points on hurricane track data and annotations, which I need to line up in a script.
I will have a point from my test text file at lat,long and annotate at font size =12,lat,long, alignment='right','center' and some of the annotations are off by an inch on the display. It seems like the annotations are about an inch longer than the hurricane track on both ends, and all mostly off in the middle. They still make a line, but just don't line up. Help me please.
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: Problems with annotations in script

Post by tomw »

Hi --

Can you send a copy of your text file, and clarify how you are reading and displaying the data? I ask because there are at least two different ways to do this.
User avatar
Weathernator
Posts: 8
Joined: Mon Dec 09, 2013 4:42 pm

Re: Problems with annotations in script

Post by Weathernator »

The test file is in format:
(index -> (Time,Latitude,Longitude,Altitude))
Time[fmt="yyyy-MM-dd HH:mm:ss"],Latitude[unit="degrees_north"],Longitude[unit="degrees_west"],Altitude[unit="feet"]
2014-06-28 20:00:00,35.33,-82.63,671
2014-06-28 20:05:00,35.53,-82.73,671
etc
etc
etc
Inside my py file:
activeDisplay().annotate("Track Point 1",size=12,alignment('right','center'),font='SansSerif.bold',lat=35.33,lon=-82.63,color='Green')
next point
next point
next point
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: Problems with annotations in script

Post by tomw »

There are a couple of possibilities -- first, the "alignment=" might be moving the labels...you might try just removing that. Second, with a proportionally-spaced font, sometimes the computation of the width of the text can produce an issue like that...you might specify a fixed-width font ("monospaced").

If none of that is working for you, would you send a few more data points along with perhaps an image of what you're seeing? Also, what version of McIDAS-V are you using?
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: Problems with annotations in script

Post by tomw »

One more note: another way to "annotate" your display would be to use the Drawing Control import/export feature (the file extension is ".xgrf". You can create a text file with information about your annotations / drawings. Refer to the "Drawing Control" section of the User Guide for details.

Here's an example of the text file -- one "symbol" of text, then a filled circle and finally 3 hurricane symbols:

<shapes>
<text color="255,0,0" coordtype="LATLON" filled="false" fontface="Dialog.bold" fontsize="12" fulllatlon="false" justification="la" marker="PIN" markerscale="0.1" name="Glyph 1" pickable="true" points="53.744747,-109.30034" showmarker="false" text="This is the &lt;b&gt;bold&lt;/b&gt; text" zposition="-0.995"/>
<symbol color="255,0,0" coordtype="LATLON" filled="false" fulllatlon="false" name="Glyph 2" pickable="true" points="39.585552,-84.4495" scale="3.0" symbol="FILLED_CIRCLE" zposition="-0.995"/>
<symbol color="255,0,0" coordtype="LATLON" filled="false" fulllatlon="false" name="Glyph 3" pickable="true" points="32.07251,-83.871574" scale="1.0" symbol="HURRICANE" zposition="-0.995"/>
<symbol color="255,0,0" coordtype="LATLON" filled="false" fulllatlon="false" name="Glyph 4" pickable="true" points="36.69592,-69.71237" scale="1.0" symbol="HURRICANE" zposition="-0.995"/>
<symbol color="255,0,0" coordtype="LATLON" filled="false" fulllatlon="false" name="Glyph 5" pickable="true" points="30.049765,-75.7806" scale="1.0" symbol="HURRICANE" zposition="-0.995"/>
</shapes>
User avatar
Rick
Posts: 404
Joined: Fri Jan 16, 2009 8:20 pm

Re: Problems with annotations in script

Post by Rick »

Follow up to TomW's request for the version number of McIDAS you are running.

Are you trying to complete the entire process in a background script or are you loading the data via the data explorer and running the annotate functions via the jython shell? We created a sample data file using the information you provided and wrote a quick script that was started from the jython shell and got good results. Please try the following:

1) Copy and paste the following code into the jython shell (I am running windows):

#
# Build a window
#
panel=buildWindow(height=800,width=800,panelTypes=MAP)

panel[0].setWireframe(False)
panel[0].setCenter(35.43,-82.68,scale=200)
panel[0].annotate("Track Point 1",size=12,alignment=( 'right','center'),font='SansSerif.bold',lat=35.33,lon=-82.63,color='Green')
panel[0].annotate("Track Point 2",size=12,alignment=( 'right','center'),font='SansSerif.bold',lat=35.53,lon=-82.73,color='Yellow')

2) From the window just create (title bar should read buildWindow)
select Projections and turn off Auto Set Projection

3) Create the following text File:
(index -> (Time,Latitude,Longitude,Altitude))
Time[fmt="yyyy-MM-dd HH:mm:ss"],Latitude[unit="degrees_north"],Longitude[unit="degrees_west"],Altitude[unit="feet"]
2014-06-28 20:00:00,35.33,82.63,671
2014-06-28 20:05:00,35.53,82.73,671

4) From the Data Sources tab in the Data Explorer window, select General -> Files/Directories
5) Use a Data Type of 'Text Point Data files' and then navigate to your files and select Add Source
6) From the Field Selector Tab, select Point Data field and Point Data Plot Display
7) Make sure the panel in the buildWindow is highlighted and then select Create Display.
8) From the Layer Controls Tab, deselect Declutter.
9) Now select the Times Tab and select Multiple.

You should now see the location points with text to the right and centered on the location point.

10) Save the image and post it.

Thanks

Rick
User avatar
Weathernator
Posts: 8
Joined: Mon Dec 09, 2013 4:42 pm

Re: Problems with annotations in script

Post by Weathernator »

Tom and Rick,
I am loading an mcv bundle. I have already tried the 800x800 panel..well 1024x1024 I was thinking that perhaps the map..might be causing some of the skew..like the annotations were in a different plane from the from the point file. It seems the aspect ratio as defined in the saved bundle is 600 x 462. Under View and Properties I set the screen dimension to 800 x 800. When I declare it in the py script it makes imagery with lettering I don't want at the bottom. I work mainly in linux, and I can get the tags to work perfectly in Windows as per Rick's suggestion. I don't have my lambert conformal wrfems grib on it though which will take me a day to download at 8+GB and test locally on my Windows machine. I wonder if the projection in the wrfems grib file is throwing off the tags. Is there a way I can make sure the tags don't interact with that data source?? Could it be taking its lat lon information from the slight skewing that probably exists in the file?
Also when I try to add the track file in linux it takes me to somewhere around India and displays the track with a giant plus sign. Did I not highlight the build window properly?
I am using the 1.4 build off of the normal download location.

Thanks for helping me so diligently!!!


Weathernator
User avatar
Weathernator
Posts: 8
Joined: Mon Dec 09, 2013 4:42 pm

Re: Problems with annotations in script

Post by Weathernator »

I think I may be on to something, so if anybody is thinking grib file, I hope that is not it. I think I may have an answer to what is happening to me. I am displaying the hurricane radar in 3D. I am essentially looking straight down on it. The tags are in the right locations I think, but the wrong altitude. They are way up high so it makes one perceive the tags as being to the left or to the right(unless they are in the middle) because they are closer to the start of the perspective and not close enough to the hurricane track. I couldn't find a tag altitude adjustment in any of the literature. Any suggestions?

Weathernator
User avatar
Rick
Posts: 404
Joined: Fri Jan 16, 2009 8:20 pm

Re: Problems with annotations in script

Post by Rick »

Labels can become distorted when viewed in 3D, so that may very well be your problem. My suggestion is to try to change the value of 671 in your text file to 0.

(index -> (Time,Latitude,Longitude,Altitude))
Time[fmt="yyyy-MM-dd HH:mm:ss"],Latitude[unit="degrees_north"],Longitude[unit="degrees_west"],Altitude[unit="feet"]
2014-06-28 20:00:00,35.33,82.63,671
2014-06-28 20:05:00,35.53,82.73,671

The problem with the points being shown in India was due to your longitude values. Your original text file had negative values for longitude and the the format specified Longitude as degrees_west (I changed the negative values to positive values) so negative degrees west ends up being in the Eastern Hemisphere. You can either remove the unit definition or change degrees_west to degrees_east. McIDAS-V defaults to East Longitude values as positive.

Let us know how things work.

Rick
User avatar
tomw
Posts: 296
Joined: Tue Dec 23, 2008 3:40 pm

Re: Problems with annotations in script

Post by tomw »

I agree about the "altitude" value....good catch!

Also, I wanted to mention that the projection should not matter since your values are located by lat/lon coordinates -- you should be able to change the projection (or use the one specified in the GRIB file), and the values will "relocated" to the lat/lon coordinates in that projection.
Post Reply