GNU Astronomy Utilities - Tasks: task #15567, Converting hh:mm:ss and dd:mm:ss...
You are not allowed to post comments on this tracker with your current authentication level.
task #15567: Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa
Submitter: | Mohammad Akhlaghi <makhlaghi> | ||
Submitted: | Tue 03 Mar 2020 12:31:31 PM UTC | ||
Should Start On: | Tue 03 Mar 2020 12:00:00 AM UTC | Should be Finished on: | Tue 03 Mar 2020 12:00:00 AM UTC |
Category: | Table | Priority: | 5 - Normal |
Item Group: | Enhancement | Status: | Done |
Privacy: | Public | Assigned to: | None |
Percent Complete: | 100% | Open/Closed: | Closed |
Effort: | 0.00 |
Jump to the original submission
Thu 09 Apr 2020 02:42:30 AM UTC, comment #57: |
Mohammad Akhlaghi <makhlaghi> |
Wed 08 Apr 2020 02:56:52 PM UTC, comment #56: I have addressed the issues and pushed the fixed commit. |
Kartik Ohri <lucifer13> |
Tue 07 Apr 2020 10:07:25 PM UTC, comment #55: Thanks Kartik. I pulled the changes but still see that the commit message title is two lines! Please correct it to be a single and complete line that is shorter than 75 characters (which can be readable with `git log --oneline').
|
Mohammad Akhlaghi <makhlaghi> |
Tue 07 Apr 2020 07:34:45 AM UTC, comment #54: I apologise for these issues. This commit message is fixed now. |
Kartik Ohri <lucifer13> |
Tue 07 Apr 2020 02:24:54 AM UTC, comment #53: I pulled the commit, and when looking at it, I couldn't go beyond the commit message!!!
|
Mohammad Akhlaghi <makhlaghi> |
Mon 06 Apr 2020 08:25:23 PM UTC, comment #52: I had mistakenly not committed those changes earlier. It should be done now. |
Kartik Ohri <lucifer13> |
Mon 06 Apr 2020 06:13:12 PM UTC, comment #51: I fetched your commit, thanks for rebasing it.
|
Mohammad Akhlaghi <makhlaghi> |
Mon 06 Apr 2020 05:08:11 PM UTC, comment #50: I have made the changes and pushed them to github. What guidelines should I follow for the commit message? |
Kartik Ohri <lucifer13> |
Mon 06 Apr 2020 01:33:06 AM UTC, comment #49: Thanks Kartik, it looks good overall, you can now rebase it over the most recent commit, and into a single commit so I do a final test and merge it.
|
Mohammad Akhlaghi <makhlaghi> |
Sun 05 Apr 2020 03:07:03 PM UTC, comment #48: I have pushed the commits adding operators to convert decimal to declination and right ascension as well. |
Kartik Ohri <lucifer13> |
Sat 04 Apr 2020 04:38:36 PM UTC, comment #47: I have added the facility to convert declination to decimal in the same way as right ascension and pushed to github. |
Kartik Ohri <lucifer13> |
Mon 30 Mar 2020 10:41:09 AM UTC, comment #46: I just saw the vice versa thing. We need to convert degrees to RA and declination as well. I'll write the necessary functions for it. |
Kartik Ohri <lucifer13> |
Sun 29 Mar 2020 12:41:48 AM UTC, comment #45: When you want to quote code, please follow the Savannah's Markup system so it is highlighted differently compared to your plain text message on Savannah, look under "Verbatim markup (useful for code bits)" for putting code.
|
Mohammad Akhlaghi <makhlaghi> |
Sat 28 Mar 2020 08:56:32 PM UTC, comment #44: I tried various operators to find the issue. This issue is not caused by the units operator. The memory leak is evident as follows this was a simple -c"arith c1 c1 +" argument.
|
Kartik Ohri <lucifer13> |
Fri 27 Mar 2020 08:13:31 PM UTC, comment #43: My copyright forms have gone through. But I wanted to ask do the copyright forms have to be in my real name or can I use an alias ? |
Kartik Ohri <lucifer13> |
Tue 24 Mar 2020 11:06:38 PM UTC, comment #42: Great! Then try your best to find the problem, it may be a good bug that you can fix (and add to your application) ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Tue 24 Mar 2020 08:07:54 PM UTC, comment #41: Sorry for the typo earlier. I wanted to say that I have fixed the errors from units.c. Please take a look at the update code again. The error I posted was coming from checkset.c. I'll take a look and try to fix this as well.
|
Kartik Ohri <lucifer13> |
Tue 24 Mar 2020 07:42:32 PM UTC, comment #40: I'd love to help, but I am just too busy these days unfortunately and given that you are just starting with Gnuastro, I think its a good exercise to master it :-). Try to fix it your self, I'll try it out as soon as I find some free time sometime in the next days.
|
Mohammad Akhlaghi <makhlaghi> |
Tue 24 Mar 2020 04:42:44 PM UTC, comment #39: I have fixed the issues. Please take a look at the error again. Valgrind still reports two errors but i don't its an issue with units.c .
|
Kartik Ohri <lucifer13> |
Mon 23 Mar 2020 05:50:40 PM UTC, comment #38: I got your branch and tried it out, but many corrections are still necessary! For example Valgrind still reports bad memory usage:
|
Mohammad Akhlaghi <makhlaghi> |
Mon 23 Mar 2020 07:44:48 AM UTC, comment #37: Hi! I have fixed this issue. The function was defaulting to GAL_TYPE_FLOAT32 which was causing the issue. I have added an extra check and it works. Instead of that, using float in the units.c might work as well. Please test this again and let me again. |
Kartik Ohri <lucifer13> |
Sun 22 Mar 2020 07:59:38 PM UTC, comment #36: You can put some test `printf' statements in various places during the process to see where this is happening ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Sun 22 Mar 2020 04:25:21 PM UTC, comment #35: Yeah sure, I'll try to debug this myself. As of now from the error log and print statements, I suspect there must be some issue in the applying the arithmetic value on the column. I want to ask if there is a way to give a string input to astarithmetic ? |
Kartik Ohri <lucifer13> |
Sun 22 Mar 2020 01:32:23 PM UTC, comment #34: Please try to debug it yourself, its a good exercise ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Sun 22 Mar 2020 01:07:17 PM UTC, comment #33: Hi! I tried using valgrind got the attached error log. |
Kartik Ohri <lucifer13> |
Sat 21 Mar 2020 07:44:11 PM UTC, comment #32: Use Valgrind ;-)! Its your best friend when dealing with segmentation faults :-)!
|
Mohammad Akhlaghi <makhlaghi> |
Sat 21 Mar 2020 07:36:30 PM UTC, comment #31: I have attached the table.txt file . I ran asttable table.txt --tableformat=txt --minmapsize=10000 --searchin=name -c1,2 -c"arith c2 ra-to-decimal and received the following output.
|
Kartik Ohri <lucifer13> |
Sat 21 Mar 2020 05:37:06 PM UTC, comment #30: This is because Gnuastro's build system doesn't yet know that it should also compile your new library ;-)!
|
Mohammad Akhlaghi <makhlaghi> |
Sat 21 Mar 2020 09:51:50 AM UTC, comment #29: I made the changes you asked. I have added a new macro in arithmetic.c for handling the string arguments in function. I am trying to run make on the project but I get the following error
|
Kartik Ohri <lucifer13> |
Fri 20 Mar 2020 10:27:39 PM UTC, comment #28: Some notes:
|
Mohammad Akhlaghi <makhlaghi> |
Fri 20 Mar 2020 09:29:59 PM UTC, comment #27: I have made the changes to the repo. I have reset my master branch and created a new units branch to make the changes. You can check the repo again at the same link. |
Kartik Ohri <lucifer13> |
Fri 20 Mar 2020 05:39:19 PM UTC, comment #26: I noticed that you have pushed your commits over the `master' branch!!! As I had described in the forking tutorial you shouldn't do this! Please read it again and follow the steps properly ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Fri 20 Mar 2020 03:29:00 PM UTC, comment #25: Hi, Here is the link https://github.com/amCap1712/gnuastro . Also, is it fine to use an alias instead of my real name? |
Kartik Ohri <lucifer13> |
Fri 20 Mar 2020 02:47:02 PM UTC, comment #24: It is easier for me to check the changes as a Git branch. Can you please fork Gnuastro, apply the changes on a new branch, push it to your own repository and give me the link? You can see the process in the Gnuastro forking tutorial. |
Mohammad Akhlaghi <makhlaghi> |
Fri 20 Mar 2020 02:07:43 PM UTC, comment #23: I have made some changes. I have attached a patch so that you can point me in the right direction. |
Kartik Ohri <lucifer13> |
Fri 20 Mar 2020 01:44:38 PM UTC, comment #22: I think as you said the code will go in a new file. I think the code will be similar to that in lib/arithmetic.c . I am adding the code in it for now so that we can proceed ahead while we wait for the copyright procedure to be completed. |
Kartik Ohri <lucifer13> |
Fri 20 Mar 2020 10:58:40 AM UTC, comment #21: I have gone through the table arithmetic program. I think what I have do is create a case like a uniary operator in gal_arithmetic function. But since the input column here is a string, whereas the examples I have seen are of numbers. Which file should I edit to add the function ? |
Kartik Ohri <lucifer13> |
Thu 19 Mar 2020 12:25:41 AM UTC, comment #20: Great! This is perfect! Just let me know when the copyright forms are complete ;-). |
Mohammad Akhlaghi <makhlaghi> |
Wed 18 Mar 2020 07:59:27 PM UTC, comment #19: Hi! I have sent an email to -email is unavailable- . Also, I have improved the units.c file as you suggested. I'll take a look into the table program. |
Kartik Ohri <lucifer13> |
Wed 18 Mar 2020 03:57:09 PM UTC, comment #18: The code is very good now, good job ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Wed 18 Mar 2020 03:05:17 PM UTC, comment #17: I'll look at it shortly, thanks.
|
Mohammad Akhlaghi <makhlaghi> |
Wed 18 Mar 2020 11:51:41 AM UTC, comment #16: I have uploaded a new file based on your guidelines. |
Kartik Ohri <lucifer13> |
Tue 17 Mar 2020 09:00:27 PM UTC, comment #15: Thank you for the code snippet and detailed advice. It will really help me to write better code in future. I had thought to comment the code once the functions were approved but I will document those side by side from now on. I will send an improved version of the code soon. |
Kartik Ohri <lucifer13> |
Tue 17 Mar 2020 12:37:32 AM UTC, comment #14: One final, and VERY IMPORTANT note: your code didn't have a single comment line! This is simply not acceptable in any large project! You need to describe every step/choice thoroughly. Even describing the peculiar behaviors of `strtod' and `strtok' in your particular usage.
|
Mohammad Akhlaghi <makhlaghi> |
Tue 17 Mar 2020 12:33:29 AM UTC, comment #13: Sorry! I forgot to clarify another point: since the parsing function may fail to parse the string, as you have done, it is often necessary to call it with an `if' statement. Its value is also not returned, but written into the argument array.
|
Mohammad Akhlaghi <makhlaghi> |
Tue 17 Mar 2020 12:27:21 AM UTC, comment #12: Please have a look at this implementation of the parsing function, which I just tried in `units.c'. Please look at the differences one by one and hopefully you'll see what I mean ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Mon 16 Mar 2020 06:26:02 AM UTC, comment #11: I have separated the low level and high level functions and tried to make improvements in readability. |
Kartik Ohri <lucifer13> |
Sun 15 Mar 2020 11:35:21 PM UTC, comment #10: Thanks for making the code so easy to test. I was able to extract your desired results with a simple `gcc units.c && ./a.out' command.
|
Mohammad Akhlaghi <makhlaghi> |
Sun 15 Mar 2020 05:20:50 AM UTC, comment #9: I have made the changes. I am using strtok as you suggested but without a loop so that the error messages can be more informative. I have added a main function and removed config.h so that you can test it easily. |
Kartik Ohri <lucifer13> |
Sat 14 Mar 2020 09:41:36 PM UTC, comment #8: Thanks Katrik. I see so many tests have been added.
|
Mohammad Akhlaghi <makhlaghi> |
Sat 14 Mar 2020 09:16:44 PM UTC, comment #7: I have improved the code. I have added sanity checks and made the code conform with GNU Coding conventions. Please take a look at the attached file and let me know if any other changes are necessary. |
Kartik Ohri <lucifer13> |
Fri 13 Mar 2020 12:39:34 AM UTC, comment #6: Thanks a lot Kartik. It look good for the first round, I think it can be merged soon ;-).
|
Mohammad Akhlaghi <makhlaghi> |
Tue 10 Mar 2020 06:43:42 PM UTC, comment #5: Sorry for the delay. I was caught up a bit in academics. I have uploaded the main.c with the code. Can you please review and provide further instructions ? |
Kartik Ohri <lucifer13> |
Tue 03 Mar 2020 06:32:13 PM UTC, comment #4: Essentially you don't need anything beyond the standard C library. You just parse the string (with 'strtok'), pull out the tree numbers, convert them to double (with 'strod'), and do the conversion :-) |
Mohammad Akhlaghi <makhlaghi> |
Tue 03 Mar 2020 05:46:42 PM UTC, comment #3: I have a few questions. Can GNULib or C standard library functions be used ? Is there anything in particular that I cannot use or I should use ? |
Kartik Ohri <lucifer13> |
Tue 03 Mar 2020 05:42:23 PM UTC, comment #2: Great! I'll do that. |
Kartik Ohri <lucifer13> |
Tue 03 Mar 2020 05:37:52 PM UTC, comment #1: To start with, it is possible to write this function completely independent of Gnuastro: as an independent function that takes a string and returns a double. In a small program as a sibgle file and easily run/test it.
|
Mohammad Akhlaghi <makhlaghi> |
Tue 03 Mar 2020 12:31:31 PM UTC, original submission:
The Right ascension (RA) and Declination (Dec) of astronomical objects is sometimes written as `hh:mm:ss' (for RA) and `dd:mm:ss' (for Dec). But in some contexts we need a single standard number (in degrees for example).
|
Mohammad Akhlaghi <makhlaghi> |
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Follow 12 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2020-04-09 | makhlaghi | Status | None | Done | |
Percent Complete | 0% | 100% | |||
Open/Closed | Open | Closed | |||
2020-03-22 | lucifer13 | Attached File | - | Added error.txt, #48649 | |
2020-03-21 | lucifer13 | Attached File | - | Added table.txt, #48635 | |
2020-03-20 | lucifer13 | Attached File | - | Added 0001-Add-units-library.patch, #48631 | |
2020-03-18 | lucifer13 | Attached File | - | Added units.c, #48623 | |
2020-03-18 | lucifer13 | Attached File | - | Added units.c, #48616 | |
2020-03-16 | lucifer13 | Attached File | - | Added units.c, #48604 | |
2020-03-15 | lucifer13 | Attached File | - | Added units.c, #48598 | |
2020-03-14 | lucifer13 | Attached File | - | Added units.c, #48597 | |
2020-03-10 | lucifer13 | Attached File | - | Added main.c, #48574 |
Powered by Savane 3.13-f8d8.
Corresponding source code
Thanks Kartik. It has been fully merged into the master branch and pushed to the main repository. I went over the changes and made some necessary corrections which can you see in Commit 4154cba9a578.
However, I had to manually add your email to the commit message! This was very annoying, especially since I had already done some of the changes in the next commit when I noticed this! So your original commit has has changed (because the email has changed), but you are ofcourse still the main author of that commit.
Please delete original branch from your remote so I can fetch your remove and remove that reference from my history.
Also, I think it will be very instructive if you look at the changes I made to your original in [the next commit.