Error 500 uploading local file in vb.net

232 views
Skip to first unread message

Jeff D

unread,
Jul 17, 2014, 5:59:23 AM7/17/14
to astro...@googlegroups.com
Hello,
I'm new to this kind of programming but I'd integrate plate solving function in a vb.net program
So far, I can login and upload a file from url but no way to upload a local file... I always get Error 500 from server
I'm using Fiddler to check the traffic and the detail of the server exception is "You cannot access body after reading from request's data stream"

In Fiddler window I can se that, after the login, I send following data

POST http://nova.astrometry.net/api/upload/ HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------635411908225739436
Host: nova.astrometry.net
Content-Length: 170804
Expect: 100-continue

---------------------------635411908225739436
Content-disposition: form-data; name="request-json"
{"publicly_visible": "y", "allow_modifications": "d", "session": "3zix4kb6arm143z46krh38v5b5ej38e6", "allow_commercial_use": "d"}"
---------------------------635411908225739436
Content-Disposition: form-data; name="file"; filename="veil_small.jpg"
Content-Type: octet-stream
/9j/43KLVvdNK3G0.....
.....
IMAGE DATA HERE
.....
.....+N3+/j4/wD9frP1n6z9B//Z
---------------------------635411908225739436


Can someone help me?

BR, J.

Dustin Lang

unread,
Jul 17, 2014, 10:57:39 AM7/17/14
to astro...@googlegroups.com
Hi,

It looks like you're off to a very good start!

Maybe this is just how the forum formatted your message, but don't you need a blank line (\r\n) separating the message headers from the message body?

(Like, between lines

Content-disposition: form-data; name="request-json"

and


{"publicly_visible": "y", "allow_modifications": "d", "session": "
3zix4kb6arm143z46krh38v5b5ej38e6", "allow_commercial_use": "d"}"

)?

I'm afraid it's not so easy for me to dig through server logs to find this error... did you notice if it gave you a long HTML error report in addition to the brief error message you gave above?  If so, any chance you could save and send that?

cheers,
--dustin

Jeff D

unread,
Jul 18, 2014, 9:51:01 AM7/18/14
to astro...@googlegroups.com
Hi Dustin,
finally I've been able to plate solve a file loaded from url, so I can exclude everything except the upload of a local file

Attached the output from the server when I try to upload a local file.

tnx, Jeff.


Error500_web_view.html

Dustin Lang

unread,
Jul 18, 2014, 12:23:08 PM7/18/14
to astro...@googlegroups.com
Thank you very much for posting that error message!

It looks like that error actually came up as it was trying to report on a failure: it didn't find the JSON content in your request.

If I were you, I would check that the required blank line between the header and content is present.  It appears to be absent in your post above.

(Note that most of the API, including URL submission, uses x/www-form-encoded, while file upload uses multipart/form-data, so being able to submit URLs does not necessarily mean everything is fine for submitting files.)

cheers,
--dustin

Jeff D

unread,
Jul 22, 2014, 4:03:20 AM7/22/14
to astro...@googlegroups.com
Hi Dustin,
now seems that the file is uploaded but the server replies "failed to parse JSON"
please, can you help?
 
BR, J.
 
MyPost.txt
ErrorJson.txt

Dustin Lang

unread,
Jul 22, 2014, 11:07:22 PM7/22/14
to astro...@googlegroups.com
Are you writing your own multipart-mime formatter?

If so, I would suggest not reinventing the wheel if you can avoid it.  If you really need to, I really think you need to verify that it is formatting the message correctly with a test service before testing against the astrometry.net service.

I would suggest reading this very closely, in particular 7.2.1 which goes through the formatting requirements.
http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

If I'm not mistaken (I am sleepy, so very well could be wrong!), the boundary you specify in the header need not start with dashes, and when it appears in the message, it is preceded by two dashes.  It looks like both the string in your header and in the body (the actual separator) contain 28 dashes.  The latter should have 30.

--dstn

Jeff D

unread,
Jul 23, 2014, 8:50:58 AM7/23/14
to astro...@googlegroups.com
Hi Dustin,

finally I solved...

it was just matter of using  HttpRequest instead of WebRequest....

....but today nova.astrometry.net don't wanna work.... a lot of fails, even using the web upload page (http://nova.astrometry.net/upload)

many thanks, Jeff.

Dustin Lang

unread,
Jul 23, 2014, 9:18:14 AM7/23/14
to astro...@googlegroups.com
Hmm, I'm not sure what was going on with the web service... gave it a reboot and seems okay now?

--dustin

Jeff D

unread,
Jul 23, 2014, 11:42:42 AM7/23/14
to astro...@googlegroups.com
Yes it is. Many thanks. Works fine from VB.

J.

Jeff D

unread,
Jul 23, 2014, 11:45:59 AM7/23/14
to astro...@googlegroups.com
Since i'm here.... "parity" i understood means image flipped, but along which axes?

J.

Dustin Lang

unread,
Jul 23, 2014, 12:50:08 PM7/23/14
to astro...@googlegroups.com
If you swap x and y, that flips the parity, or if you flip over either x or y axis.  Rotating it does not.  It's kind of like the "right hand rule"; is the positive y axis counter-clockwise or clockwise from the positive x axis.

Jeff D

unread,
Jul 23, 2014, 5:08:34 PM7/23/14
to astro...@googlegroups.com


Il giorno mercoledì 23 luglio 2014 18:50:08 UTC+2, Dustin Lang ha scritto:
If you swap x and y, that flips the parity, or if you flip over either x or y axis.  Rotating it does not.  It's kind of like the "right hand rule"; is the positive y axis counter-clockwise or clockwise from the positive x axis.

maybe I didn't get your point......
considering Z-axes a vector out of the plane point at you,  if you flip both X and Y you get a 180° rotation of the original image, ok? that means no parity, just rotation
but if you have only a flip without knowing along which axes, how can you be sure it's X rather than Y?

just for my understanding.

tnx, J.

Dustin Lang

unread,
Jul 23, 2014, 9:36:03 PM7/23/14
to astro...@googlegroups.com
If you flip over X and then Y, yes, that's just a rotation.  But if you flip over only one, doesn't matter which one, that flips the parity.  Flipping over the X axis and then rotating is equivalent to flipping over the Y axis.

The geometric features that the astrometry solver uses are invariant under translation, scaling, and rotation, so we can handle the unknown rotation, but not the parity, so if we don't know it, we have to try both parities (flipped and not-flipped).

cheers,
--dustin


Jeff D

unread,
Jul 24, 2014, 3:44:14 AM7/24/14
to astro...@googlegroups.com
hmmm, I understand you just need to plate solve the image and flipping over one axes it's enough, but this is a problem to me....
I'm making a program that helps in planning mosaics. You can load an image on the background and overlap the array of frames.
Knowing image scale, frame center and orientation, you can have a preview of the final result, and get the list of the centers.
When parity is 1 everything is fine (seems that 1 is 'no flip' in VB), but when the parity is -1 I'll not be able to determine the correct rotation if I flip over a 'random' axes... am I right?
At the and, I'll warn the user that the image is flipped without knowing over which axes. Probably I'll ask to choose between the possible 'reconstruction', but this is another story....

Here a list of four jobs with results.
Just reading the results, and not the file name, I can't see a way to understand how did I flip the image.


##########################################################################
file = veil_original.jpg
parity = 1,0
orientation = 178,58037178879894
pixscale = 10,645073829122717
radius = 3,700641933438485
ra = 313,2328088873419
dec = 30,935557858481214


##########################################################################
file = veil_x_flipped.jpg
parity = -1,0
orientation = -1,4198660572702217
pixscale = 10,645082393077045
radius = 3,700644910602289
ra = 313,2328194076941
dec = 30,935485274571718


##########################################################################
file = veil_y_flipped.jpg
parity = -1,0
orientation = 178,57913072415607
pixscale = 10,645071740276999
radius = 3,700641207274422
ra = 313,23284530939657
dec = 30,93554861278499


##########################################################################
file = veil_original_rotated_20degrees_CW.jpg
parity = 1,0
orientation = -161,39248374087225
pixscale = 10,644615516602892
radius = 4,7095966156832985
ra = 313,23141442927
dec = 30,9355148129884


BR, Jeff.

Dustin Lang

unread,
Jul 25, 2014, 8:48:26 AM7/25/14
to astro...@googlegroups.com
The real answer is to use the full WCS solution.  Parity = sign(det(CD matrix)), and the elements of the CD matrix transform between pixel coords and sky coords.  But I bet that if you try out flipping the image over x, flipping the image over y, or transposing the image, one of those three will work.

cheers,
--dustin


Jeff D

unread,
Sep 3, 2014, 8:36:51 AM9/3/14
to astro...@googlegroups.com
Hi Dustin,
ok, checking the parity I can understand if the image is flipped, but how can I understand over which axis?
Which params in wsc.fits should I use? and how?

tnx, J.

Dustin Lang

unread,
Sep 3, 2014, 9:06:39 AM9/3/14
to astro...@googlegroups.com
CD1_1 is basically the derivative dRA/dx
CD1_2 is dRA/dy
CD2_1 is dDec/dx
CD2_2 is dDec/dy

(it's not exactly RA,Dec, it's projected "intermediate world coordinates", but you get the idea)

cheers,
--dustin

Jeff D

unread,
Sep 4, 2014, 11:46:26 AM9/4/14
to astro...@googlegroups.com
Hi,
dRA/dx means variation of RA over pixel position? positive if RA increases as px number increases?
if so, pixel 0,0 is top left as in bitmaps?

tnx, J.

Dustin Lang

unread,
Sep 4, 2014, 3:51:50 PM9/4/14
to astro...@googlegroups.com
Yep, dRA/dx is how much RA increases per pixel in the x direction, positive if RA increases with x.

The CDx_y matrix elements refer to FITS images.  There is always disagreement when converting from FITS to jpeg whether one should flip the image or not.

The FITS viewer 'ds9' shows FITS images with pixel 1,1 (first pixel in FITS indexing convention is 1,1, not 0,0) in the bottom left, which is opposite what most jpeg and other bitmap formats do, where pixel 0,0 is top-left.

What is the problem you are trying to solve?

I was going to say that you could check by looking at the grid lines plotted on your image, but I see now that the web service doesn't do that... you could try the "plotann.py" script, or send an example nova.astrometry.net submission URL and I can run it for you.

cheers,
--dustin



Jeff D

unread,
Sep 4, 2014, 5:09:42 PM9/4/14
to astro...@googlegroups.com
Hi Dustin
that's the issue:
I'd use data of plate solved images in a program I've made to help planning mosaics. The image is shown in background so you have a real time preview of mosaic size and final result. Knowing image center, scale and orientation the program gives you back the list of the frame centers. As you can understand, if the image is flipped the coords will be wrong.....
With your clarification I think that using CD matrix data I'll be able to identify over which axes the image is flipped, if it is.
Now, if parity isn't ok, I just warn the user but I'd like to flip back the image automatically.
Let's see what happens.
Thanks so far, J.

Dustin Lang

unread,
Sep 5, 2014, 9:19:24 AM9/5/14
to
Hi,

If you have a recent version of the astrometry.net code installed, with the python utilities ("make py"), you could try a script like the attached map.py:

wget "http://nova.astrometry.net/wcs_file/832511" -O wcs.fits
wget "http://nova.astrometry.net/image/776441?filename=image.jpg" -O image.jpg
python map.py
open [12].png

cheers,
--dustin

(ps, that's this image: http://nova.astrometry.net/user_images/394557#annotated)




map.py
1.png
2.png
Reply all
Reply to author
Forward
0 new messages