omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Binary files read and write

    Pythonista
    8
    99
    91751
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ManuelU
      ManuelU last edited by

      Not yet, but of course is useful to process SPL data in the Pytonista enviroment. I'll try it with a full 24 record of a MD that works transporting critical patients in an Ambulance. I sent him the SPLnFFT App. The record will be done with an iPhone 6. I'll send you the results when they are available. Another practical application is to monitor at bed time people that snores since they're prone to sleep apnea that may be dangerous for health. The measures of the app are accurate and render the same SPL values of that registered with a professional class 2 SPL meter that I use to calibrate it. By the way there are a free sample for evaluation of techBasic, the techSampler. There you can observe how easy is to plot high quality graphics with pinch gestures.

      1 Reply Last reply Reply Quote 0
      • ManuelU
        ManuelU last edited by

        JonB, If you're talking about a new beta update of phytonista the answer is no. If is about the template to compile the scripts into a stand alone app with Xcode, the answer is yes; I downloaded yesterday the Zip file that will be installed in a Mac mini with Yosemite when I solve the problem of repeated phishing attempts that my antivirus blocks. It seems it's related to the Apple Store ID . I also have read the code for resampling the SPLnFFT data to plot graphics with pinch gestures. Since I'm a beginner in Phytonista, It's complicated for me to understand how you link the SPLnFFT data file to this script.

        1 Reply Last reply Reply Quote 0
        • ManuelU
          ManuelU last edited by

          CCC, this is going to make you happy. This is the processing time of a 15 hours continuos recording with SPLnWATCH, a child App of SPLnFFT. It records in the background with a minimal battery usage (about 13%)
          Elapsed time (3 Starting scatter...): 0:00:01.277414
          Elapsed time (2 Scatter): 0:00:19.745673
          Elapsed time (1 Adornments): 0:00:19.818221
          Elapsed time (0 plt.show() Done.): 0:02:09.151619

          The graph output is nice an fit well to the recording tines. I wish I new how to send it to you because I'll try to make it with your latest option by hours chunks.
          CONGRATULATIONS FOR YOUR GREAT SCRIPT.

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by ccc

            I wish I [k]new how to send it to you

            If you have a free login to GitHub, you should be able to go to https://github.com/cclauss/SPLnFFT_tools and click the "+" to add a new file to the repository. Provide a reasonable name with the proper extension (.png, .jpg, etc.). You will then have to click the "Propose new file" and then "Create pull request" button a few times.

            1 Reply Last reply Reply Quote 0
            • ManuelU
              ManuelU last edited by

              I made a screenshot and sent the image to the Twitter account @olemoritz to send it to you. Do you have a Twitter account?. It's simpler for me

              1 Reply Last reply Reply Quote 0
              • ccc
                ccc last edited by ccc

                This is the image that I got from @ManuelU via Twitter.

                It shows why we want to preprocess our SPLnFTT.bin data files with SPLnFFT_strip.py. The hours from 14h thru 24h contain all zeros. That script would remove those null hours which would

                1. decrease file size
                2. reduce upload time, and
                3. give us higher resolution plots.

                And here is a plot from his TechBasic program:

                1 Reply Last reply Reply Quote 0
                • ccc
                  ccc last edited by ccc

                  @ManuelU, I created a new repo https://github.com/cclauss/SPLnFFT_tools for the code from this thread and updated the links above to point to that repo. I have also included a new binary file of me snoring. Please tell me what the threshold of danger is for snoring. My wife assures me that I am way over that limit but it would be good to get a second opinion.

                  Do I understand SPLnWATCH correctly? Is that an AppleWatch app that records noise levels? If so, we could get @Phuket2 to use it to tell us which of his favorite bars has the most impressive Sound Pressure Levels.

                  Phuket2 1 Reply Last reply Reply Quote 0
                  • Phuket2
                    Phuket2 @ccc last edited by

                    @ccc , LOL, yes I will be the data collector for the bars. Some poor soul like me has to do it :) I also have netatmo (inside, outside and rain module) but the last time I looked I thought there was no python API. I also have Phillips Hue lights. I have seen there are modules to interact with the hue lights API (I think on the tools site). But could be funny to have your snoring levels controlling the lights :)

                    ccc 1 Reply Last reply Reply Quote 0
                    • ManuelU
                      ManuelU last edited by

                      Hi. It depends on frequecy during the whole sleep time, the apnea periodos and the background medical context for each person. Right now I don't know what are the critical values for both parameters. I'll make a peer view on the topic in Internet and I'll.send to you the best links. Key words would be: sleep apnea etiology clinics ,diagnostic and treatment. I record noise with the iPad version of SPLnWATC I, think it's universal, but you need to adjust the settings in the mother App, SPLnFFT. I use the watch version because can record in the background, which supposes a battery and screen saver. You haw to buy the 24 hours record option and have a Dropbox account. that's all. Hope it helps

                      1 Reply Last reply Reply Quote 0
                      • ccc
                        ccc @Phuket2 last edited by

                        @Phuket2 Netatmo https://github.com/philippelt/netatmo-api-python

                        Phuket2 1 Reply Last reply Reply Quote 0
                        • Phuket2
                          Phuket2 @ccc last edited by

                          @ccc , thanks. Is great to have. In itself, not Exciting (the dashboard app is great), but combined with hue lights could be a lot of fun. I know if than then, but it's just too slow to have real time fun :)

                          1 Reply Last reply Reply Quote 0
                          • JonB
                            JonB last edited by

                            here is a slightly different take (on the original wuestion:dynamic matplotlibs). this one is written so it should be compatible with 1.5, as it uses plain touch handling.

                            the approach i took was as follows: there are zoomable scrollbars in top and size, which van be pinched or scrolled. the width of the bar represents the fraction of a day on the screen. i dont have the skeomorphism tuned quite right, it is slightly awkward i admit. finer panning can be achieved by pulling finger down away from the bar while dragging, similar to the way videos work in safari.

                            after computing the zoom limits, the way i deal with the millions of points is to resample down to just a few hundred points on the scren... which after all is about all you can see anyway given fixed resolution of the device. i do that by calculating how many of the original data points lie within each resampled point, and then compute the peak signal (for the fast data) and log average (for the slow), then only plot those points. in addition, setting the dpi for the matplotlib image low during dragging makes this reasonably responsive.

                            One thing i learned... ui.in_background is not the same as as threading.Thread... the former seems to queue up commands all on a single background thread, rather than creating a new thread each time. hence the run_async decorator which i copied from SO.

                            Imgur

                            see ZoomSlider and SPLView11 at
                            https://github.com/jsbain/uicomponents

                            Next TODO would be to add single touch data "cursor" inside the plot.

                            1 Reply Last reply Reply Quote 0
                            • ccc
                              ccc last edited by

                              @ManuelU, generating new hourly files with this new version of SPLnFFT_hourly_split.py should allow you to plot them again.

                              1 Reply Last reply Reply Quote 0
                              • ManuelU
                                ManuelU last edited by

                                @ccc I noticed now that iTunes File Sharing is not supported even when you connect your iOS device with a cable to a desktop computer

                                1 Reply Last reply Reply Quote 0
                                • Webmaster4o
                                  Webmaster4o last edited by

                                  @ManuelU this was changed in Build 160025. From the release notes:

                                  iTunes File Sharing is no longer enabled (this was temporary anyway, but with the new internal directory structure, it wouldn't actually work anymore)

                                  1 Reply Last reply Reply Quote 0
                                  • ManuelU
                                    ManuelU last edited by

                                    @webmaster is there an Android or desktop version of Phytonista?

                                    dgelessus 1 Reply Last reply Reply Quote 0
                                    • dgelessus
                                      dgelessus @ManuelU last edited by

                                      @ManuelU Yes, it's called Python. ;) Of course Pythonista comes with some third-party modules (like numpy and matplotlib) that are not part of the Python standard library, those need to be installed separately. You can do that using the pip command (pip install numpy), or by installing a Python distribution like Anaconda that includes many third-party libraries. Pythonista-specific modules like ui are of course not available on normal computers.

                                      1 Reply Last reply Reply Quote 0
                                      • ManuelU
                                        ManuelU last edited by

                                        @CCC the rule of thumb I use to assess if SLOW and FAST SPL VALUES have not been swapped in the cleansing process is that the start time should always be an odd number and the end time should always be an even number. I noticed that it could happen when reviewing a file that started with a NAN and when eliminated the next register, a fast measurement , was taken as a slow measurement. This may happen if you read the values in a 1D vector and then you transform in a 2D matrix

                                        1 Reply Last reply Reply Quote 0
                                        • ccc
                                          ccc last edited by ccc

                                          @ManuelU When you say even and odd, are you talking about zero-based numbering like Python or one-based numbering like TechBasic? If zero-based then the very first element in the binary file is even. If one-based then the very first element in the binary file is odd. Thus the Python programmer and the TechBasic will not agree about even and odd.

                                          My current code does not reverse the slow and fast values and it does not detect Infs and NaNs and does no data cleansing.

                                          The code reads in slow,fast pairs into one long two column array. It the writes the first 1/24 th of that array into the 00h_to_01h.bin file (0h00 to 0h59). It writes the second 1/24th of that array into the 01h_to_02h.bin file (1h00 to 1h59).

                                          If you would like the code to do something different, please open an issue and I will see what I can do.

                                          1 Reply Last reply Reply Quote 0
                                          • ManuelU
                                            ManuelU last edited by

                                            @ccc it's one based arrays. If Python is zero based then is right and your script works fine and at an incredible speed for an interpreter.
                                            I just call your attention on this line of code of your script that is not flagged : t_bad=t[(fast<=0) | (slow <= 0)]. As far as I know, negative SPL readings arise when infinites values are recorded and could happen if you have a telephone call in your iPhone while running the App. I only use iPad with no cellular. It seems that in the latest versions of both Apps this bug has been corrected, but I follow the general principle that no programm is bugless. Thank a lot for you nice attention and your work on this topic.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors